[Desire Android Development] moebius83:
If you are like me and you like your stock Desire rom, you rooted it using unrEVOked or some other methods, you made some custom adjustment to it and you really don't want to load a fully fledged 3rd party rom but still, you'd like to tweak it a little bit more, you'll quickly realize that you are going to need a working init.d system in order to start custom scripts on boot.

This thread will try to explain how to add init.d support to your rom, without needing to flash a new rom and wipe everything, we're just going to flash a new boot.img.

Requirements

Rooted HTC Desire

New modified boot.img, supported firmware versions: 2.10.405.2, 2.29.405.2/5, check your firmware version here: (Settings -> About Phone -> Software information -> Software number)

Download this one: View attachment 477294 if your "Software number" is: 2.10.405.2

Download this one: View attachment 477295 if your "Software number" is: 2.29.405.2 or 2.29.405.5

Make sure you download the one matching your "Software number", the wrong one will cause boot loops and weird behaviors.

ADB shell access

flash_image binary, usually provided by unrEVOked under /data/local/flash_image but if you don't have grab it here: View attachment 477293

busybox correctly installed under /system/xbin

HOW-TO

NOTE

: if your Desire is not S-OFF (meaning you can't write to the /system directory), you'll need to do the whole procedure in recovery mode.

Do a nandroid backup, this in order to save your current boot.img, and also because it's never a bad idea :)

Make sure the nandroid backup went ok

Check your exact firmware version (Settings -> About Phone -> Software information -> Software number) and download the corresponding modified boot.img

Copy and unzip the downloaded boot.img to your sdcard or wherever you like it

Obtain adb shell access, become root (su) and wipe the existing boot image with:

cat /dev/zero > /dev/mtd/mtd2

ignore the "write: No space left on device", it's normal.

Flash the new boot image:

flash_image boot /sdcard/boot.img

where "/sdcard/boot.img" is the path where you copied the downloaded boot.img

Remount the /system partition read-write if you're not in recovery mode:

mount -o remount,rw /system

or mount it if you are in recovery mode:

mount /system

Create the init.d directory where all the custom boot scripts will be executed:

mkdir /system/etc/init.d

and set permissions:

chmod 755 /system/etc/init.d

Important: unzip and copy the View attachment 477292 script to the newly created /system/etc/init.d/99complete, set permissions:

chmod 755 /system/etc/init.d/99complete

and ownership:

chown root.shell /system/etc/init.d/99complete

Failure to do so will cause a boot loops.

Cross your fingers and reboot! If anything goes wrong you can always boot into recovery and fix errors or you can restore the nandroid backup (you can just restore the boot.img if you don't want to do a full restore).

From now on, every script you put inside /system/etc/init.d will be executed at boot before almost any other initializations. Make sure you set the correct permissions to your scripts (i.e. 755).

Thanks to: teppic74 for providing stock roms with init.d support (thread) where I extracted the boot images.