Android - How to run a script on boot in CM12.1?
there is a simple method to add init.d support to any rooted android for versions 4.0 and above ,google made a script that runs at boot as superuser the script is
install-recovery.shit is used to reflash stock recovery at every boot they thought it was a good security to prevent custom recoveries but it opened a new hole that can be exploited by users to fake init.d feature.
Dependencies : in order to this method to work you need the following
- Busy box installed with the
run-partssymlinked to your path like
- Obviously you gonna need a rooted phone with the
/systemable to mount as
- kernel version doesn't matter.
Method I : (The easiest way !)
- Download this APK (free to use,don't mirror, thanks @Ryuinferno from XDA).
- Install the apk like any normal app.
- Launch the app.
- click on Activate ! that's it you're all setinit.d is now supported you can click the test button or reboot your phone to see if your init.d scripts are exited
- you can uninstall the application it wil not affect the init.d support
Method II : (difficulty: medium)
Download this zip unzip it and put init.sh on your sdcard (in this exmple it's gonna be
/sdcardit can change from device to other.
now open a terminal ,or use
adb shellfrom computer and run the script.
cp /sdcard/init.sh /data/tmp/init.sh
chmod 777 /data/tmp/init.sh
the script will run and ask you to reboot twice ,that's it you have officially init.d support :D
Reference: [MOD][APK+SCRIPT+ZIP] Enable Init.d for Any Phones w/o Need of Custom Kernels!!!
Edit: I saw end off post, This one way, I will try to add without apps ASAP (not home, publishing using mobile), but you can use this, if anything other does not work.
You can try using app called Tasker.
It costs 3.29$ and require root access but it can run Shell scripts. Also, it have Trial version so you can try before buying.
First create Task. Go to Task tab, tap + sign, enter task name. Now go again + sign, and type
shell in filter. You will find option
Run Shell, select it, and configure it per your needs.
After that go back to first tab - Profiles, tap + sign to create new. Select Event as type, go System and select Device Boot. Go back and you will be asked to select task. Now select previusly created task and you are ready to go!