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

  1. Busy box installed with the run-partssymlinked to your path like /system/xbin
  2. Obviously you gonna need a rooted phone with the /system able to mount as rw
  3. kernel version doesn't matter.

Method I : (The easiest way !)

  1. Download this APK (free to use,don't mirror, thanks @Ryuinferno from XDA).
  2. Install the apk like any normal app.
  3. Launch the app.
  4. 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
  5. you can uninstall the application it wil not affect the init.d support

Method II : (difficulty: medium)

  1. Download this zip unzip it and put init.sh on your sdcard (in this exmple it's gonna be /sdcard it can change from device to other.

  2. now open a terminal ,or use adb shell from computer and run the script.
    su
    cp /sdcard/init.sh /data/tmp/init.sh
    chmod 777 /data/tmp/init.sh
    /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!