Archive for category hacking

Quick and Simple Server SMTP

I have a number of servers that I look after in various places on the intertubes. I like to have things like MDADM (Linux software RAID manager) be able to mail me when the something goes wrong like a disk dies etc.

Some of these machines are in places without reliable SMTP servers for me to send mail through and I’ve tried running my own postfix and delivering the mail directly, but invariably I run into situations where the servers that I’m trying to deliver mail to don’t like DSL IPs… and not getting a mail about a dead disk is kinda a big issue.

I also don’t trust a lot of ISP’s SMTP, and some of my servers move around, so one day it’ll be behind a DSL IP and the next behind a Verizon IP (where it can’t talk to smtp.dslprovider.net etc).

My solution is quite simple, use google. (This guide is for Ubuntu but I’m sure you’ll figure it out with other distros)

  1. Create a gmail account for monitoring. I do this because I don’t want my gmail password floating around in plaintext on various machines.
  2. Install the ca-certificates package

    $ sudo aptitude install ca-certificates
    $ sudo update-ca-certificates

  3. Install msmtp

    $ sudo apt-get install msmtp

  4. Configure msmtp

    $ sudo vim /etc/msmtprc

    Set it to something like

    account gmail
    host smtp.gmail.com
    from myemailaddress@gmail.com
    auth on
    tls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    user notifyemailaddress@gmail.com
    password mys3cr3tp455w0rd
    port 587

    account default : gmail

  5. Create a sendmail simlink

    $ sudo ln -s /usr/bin/msmtp /usr/sbin/sendmail

  6. Run a test

    $ echo “This is a an awesome test email” | msmtp youremail@domain.com

  7. If you want mdadm to mail you when something goes wrong

    $ sudo vim /etc/mdadm/mdadm.conf

    and put your email address on the line that reads something like

    MAILADDR youremail@domain.com

  8. And then run a mdadm test by running

    $ sudo mdadm –monitor –scan –test –oneshot

  9. If everything is working according to plan you should receive an email. You can now rest assured that any future MDADM issues will get to you.
1 Comment

Android for noobs and Heroes!

Some of my non-technical friends mentioned that all this Android stuff sounds great but they don’t understand any of it. So here is a very brief introduction. Android is a (mostly) Open Source operating system initially developed by Google and subsequently taken over by the Open Handset Alliance (OHA). This means that instead of every phone manufacturer working on building their own operating systems in isolation, the members of the OHA all work together to make Android better, fixing bugs and writing new apps.

Just a little teaser... I've subsequently installed the Hero ROM... and it is beautiful.

My Magic running Hero with TouchFLO.

This does mean that a relatively unknown manufacturer like Huawei could build a phone to Android specifications, install Android on it and reap the rewards of work that HTC employees had done. Phone manufacturers can chose to keep applications to themselves, like HTC has done with the user interface app called TouchFlo that they released on their new Hero Android phone. However the Open Source license states that if HTC makes any changes to the core Android system (ie, fixing a bug or adding a new feature) those changes have to be shared with the rest of the the Android community.

While all the OHA members, (Google, Intel, Nvidia, HTC, LG, Motorolla, Samsung, Asus, Garmin, Huawei, Sony Ericsson, Toshiba, Acer and more)  work together to build a better phone operating system, there are also a bunch of independent nerds in their nerd rooms building cool apps and fixing bugs for free. (Some developers can charge for their apps)

This is great for the consumer because not only do you get a great operating system and great apps but you also get well priced phones because there is always pressure from the little known phone manufacturers in China etc bringing out a really cheap Android phone. This also means that phone manufacturers can focus on building good quality phones with great cameras etc instead of wasting time with the OS.

While Apple’s iPhone does have a more mature ecosystem, the speed at which Android is currently moving makes me think that their lead will only last for a few more months. Case in point is the ridiculous speed at which new ROMs (A ROM is basically a big file containing the entire operating system) are being released by the Android community. I don’t think I’d be exaggerating if I said there was a new ROM available ever second day.

Which brings me to the part that my nerd friends want to hear about. Running the HERO Rom on my Magic. To clear this up for the non-nerds, what I’m doing here is running an Operating System theoretically built for HTC’s newest phone, the Hero, on my HTC Magic. The fact that this is even possible is entirely due to the fact that these phones run Android. While it may have been possible to do it with other phones in the past, the process would have been exceedingly complicated and probably impossible.

The Process: It was easy, I put the update.zip on my phones’ SD card, booted into fastboot mode, fastbooted the recovery image and applied the update.zip. It took about 2 minutes in total.

The OS: There are a few new things:

  • New keyboard with longpress for things like numbers and symbols ($%#()!) etc. This is great.
  • New Social Networking integration. When you’re setting it up it asks for your twitter, facebook and flickr details. From then on uploading a picture to any of those is a one “click” process. The built in Twitter client, Peep, is pretty nice too.
  • TouchFLO is very pretty but it really needs to be equated to Vista… It is CPU intensive and therefore your battery life is decreased. I used Touch Flo for a few days and then turned it off, which essentially makes the phone look like the traditional Android interface and increase the battery life. TouchFLO does have some nice widgets that are not available once you disable TouchFLO.
  • There are some new non-TouchFLO widgets that come bundled with the image (A neater calendar widget is one) but I think these are probably all available on Android Martket.

Now that I’m back to running the standard Android UI, I do believe that the Hero ROM has increased my battery live compared to the stock image that the phone came with.

All in all I’m very happy with the Hero ROM and I certainly won’t be going back. ;)

j.

12 Comments

Rooting a Vodacom HTC Magic and upgrading the firmware in South Africa to get Android Market and more.

If you’re in South Africa and you own an HTC Magic Android phone you’ll soon realise that it’s missing Android Market, which to be honest, is pretty much what makes Android so damn amazing in the first place. In its place is the Leaf Open Market. Leaf are the South African HTC importers. Open Market is about as awesome as getting stabbed in the eye with a pencil, repeatedly. The application works okay, but the selection of applications is incredibly dismal.

Update 30/06/09: There are rumblings that Leaf is going to “release” Market in “two weeks”. Supposedly they’re going to be sending out instructions on how to ROM your phone or allowing you to take it into a vodacom store and getting it ROM’d there (most likely they’ll need to send it away). I have no idea how true these claims are. Maybe someone wants to phone Leaf and ask them?

Update 23/07/09: A really good resource for anyone looking to hack their Magic is the XDA-Developers Forum. Some kind souls have also recently added a Wiki specifically put together for hacking the Magic (Sapphire) which every one of you should read from start to finish.

Anyway, the primary reason I love Android is because it’s hackable. Commence hacking. Warning: Yes, this probably will void your warranty. Yes, it’s possible that the real Android Market will eventually be released in SA, but I’m not holding my breath.

Basically what we’re doing here is updating the phone’s firmware to the version HTC originally intended the Magic to ship with… There are stacks of other firmwares (called ROM’s in the ‘community’) floating around, I’m just pointing to one that definitely works. Using the wrong ROM can put your phone in a state where it refuses to boot… Never fear, see below ‘Recovering from a bricked Magic‘.

General Steps

I’m going to explain the general steps you go through first… This will help you understand what it is you’re about to do so that you aren’t just blindly following instructions.

  1. We get the Android SDK and Fastboot applications installed on our computer
  2. We copy the ROM we want to install onto the SD Card and rename it ‘update.zip’
  3. We boot the phone into FASTBOOT mode.
  4. Using the FASTBOOT program we temporarily upload and ‘install’ the daldroid-recovery.img ROM over USB. (This is a special boot loader app that lets us do cool stuff like made Nandroid backups and install that update.zip ROM from the SD Card.)
  5. The phone boots into the daldroid-recovery mode.
  6. We backup our original ROM to the SD Card using Nandoid, clear some settings and then install the new ROM.
  7. Congratulations, you have a rooted, real android phone ;)

Step by Step Instructions

Okay, now that you know the basic steps, here are the details.

  1. Enable USB debugging on the device in Settings->Applications->Development->”USB Debugging”
  2. Ensure you have the Android SDK downloaded, and the included USB driver installed correctly on your desktop.
  3. Download Fastboot. Since I use linux I just copied the ‘fastboot’ binary to the Android SDK’s tools directory and made it executable.
  4. Open up a terminal/dos prompt and “cd” to the tools directory in your Android SDK folder.
  5. Plug in your USB Cable.
  6. Run the following command:
    adb devices

    Linux users will need to run:

    sudo ./adb devices
  7. You should see your Android phone’s serial in the list. If you get an empty list, you need to sort out your USB driver.
  8. Download Daldroid’s Rooted (adb shell) Original HTC ROM for Magic and Daldroid’s Recovery Image
  9. Unzip the daldroid-recovery.zip file and put it in the Android SDK’s tools directory.
  10. Connect the phone with the USB cable and from the notifications bar, mount the SD card. Rename daldroid-htcmagic1-signed.zip to update.zip and copy it to the phone’s SD card.
  11. On your device, enter the bootloader FASTBOOT mode by turning off the phone and then, while it is off, pressing the volume down button while pressing the power button.
  12. You should get a screen with some androids on skateboards at the bottom…Give it a second to run whatever tests it runs.
  13. Pressing the back button will get you into FASTBOOT MODE and you should see the screen change to say ‘FASTBOOT USB’
  14. Type the following commands on your computer (not on the device):
    fastboot boot daldroid-recovery.img

    Again, Linux users will need to run:

    sudo ./fastboot boot daldroid-recovery.img
  15. This will upload (over usb) a mini recovery image and reboot your phone… It’ll take a few seconds and you’ll be prompted with the recovery interface.
  16. Select ‘Nandroid Backup 2.1′ from the menu. This will write a backup of your existing system to the SD card… useful in case something goes wrong.
  17. Select ‘Wipe Data/factory reset’. This erases settings etc that might not be compatible with the new firmware
  18. Select ‘Apply sdcard:update.zip’. This essentially installs the system image from the update.zip file.
  19. Select ‘reboot system now’.
  20. Wait a long time for the first initialization. Congratulations, you have a real, rooted, Android phone with Android Market and thousands of quality apps to install.

The really nice thing about the Daldroid image is that it comes with all the APN settings etc required for Vodacom so your HSDPA will work straight away.

Recovering from a ‘Bricked’ Magic

I promised earlier I would tell you how to recover from a ‘Bricked’ Android phone… I’ve put ‘bricked’ in quotes because a lot of people seem to be thinking they’ve bricked their phones when in reality it’s quite easy to recover.

  1. Check if you can get to into Fastboot Mode:
    1. Remove the battery.
    2. Wait 10 seconds (or more)
    3. While pressing the volume down button, pop the battery back in.
    4. If it doesn’t turn on by itself, keep pressing the volume down button and press the power button.
    5. You should get the Fastboot menu.
    6. If you don’t get into Fastboot mode, try a few more times and then panic. I don’t know how to help you. Try Google.
  2. You now need to copy the right update.zip (see step 8 above) onto your SD Card. There are two ways:
    1. Get a usb card reader or use another cell phone that will allow you to mount the SD Card over USB and just copy it.
    2. or, the slightly fancier way, while your phone is in Fastboot mode run the following command on your computer (first put the new update.zip in your Android SDK tools directory):
      adb push update.zip /sdcard/update.zip

      Again, Linux users will need to run:

      sudo ./adb push update.zip /sdcard/update.zip

      This uploads the file directly onto the SD Card via USB. It takes a minute or two so do be patient.

  3. Now you just need to follow steps 11 though 20 from the instructions above and you should be golden.

Updated (21 June 2009) – Putting the original Vodacom ROM back

If for some or other reason you want to go back to the old version of the Vodacom ROM, you can do so quite easily.

Nandroid writes a selection of files to the SD Card:

2.5M  boot.img
339K  cache.img
60M   data.img
256K  misc.img
265    nandroid.md5
5.0M  recovery.img
78M   system.img

You should really make a copy of them on your local machine just in case. Once you’ve got those files on your local machine you can restore your phone using fastboot like so:

  1. Copy the nandroid files (*.img) from your backup into your SDK Tools Directory.
  2. Boot your phone into Fastboot mode (Steps 11, 12, 13) from the Step by Step guide above.
  3. Run the following commands from your computer:
    fastboot erase system -w
    fastboot erase boot
    fastboot flash system system.img
    fastboot flash userdata data.img
    fastboot flash boot boot.img
    fastboot reboot
  4. Congratulations, you now have your old Vodacom phone back. :/

Hope this helps, feel free to ask questions.

83 Comments

More awesome recycled music

This is a floppy drive:

Plus a link to an article that explains how to turn a hard drive into a speaker.
http://www.hodcroft.net/?s=4&p=speaker
Lourens, I know you have hard drives lying around.

j

No Comments