Last Updated on Dec 26, 2022
Disclaimer: I am not responsible for you doing things wrong and breaking your phone or losing your data.
I recently found out that my debuggerd hack to enable init.d support on my stock SGS4 wasn’t working. So, I did this and now it works.
Make a file named “install-recovery.sh” and drop it into /system/etc. Whatever script you put in here will execute at boot up so long as the user/permissions are correct.
chown shell:shell "/system/etc/install-recovery.sh" chmod 755 "/system/etc/install-recovery.sh" chmod u=rwx,a=rx "/system/etc/install-recovery.sh" # busybox must support symbolic modes
My “/system/etc/install-recovery.sh” script:
#!/system/bin/sh LOG="/data/install-recovery.log"; echo "Executing install-recovery.sh" > $LOG; echo "" >> $LOG; echo "$(date) install-recovery hack..." > $LOG echo "" >> $LOG echo "init.d" >> $LOG # I can't get run-parts to work for some reason, but this will run every *.sh script in /system/etc/init.d as root. for N in /system/etc/init.d/*.sh; do su -c "$N" 1>>$LOG 2>>$LOG done;
Notes:
- Mount binding (in JB 4.2.2+) seems to work. E.g. mount -o bind /folder1 /folder2
- $(date) does not provide the correct date (mine said: “Wed Apr 15 13:24:13 MST 1970”).
- The Package Manager is not available. (There may be other unavailabilities, but I don’t intend to test it thoroughly.)