1

This looks like a general concern of rookie Android system players who have just rooted their phones. The most prevalent method may be throwing your script into /system/etc/init.d. If the ROM supports init.d then Voila but that's not always the case. So

How can I run my custom script at each startup? What's the user/group my script will be running as if I use your solution?


We welcome all kinds of solutions.

1

3 Answers 3

1

Simple way (working):

  1. Prepare your post boot commands in a script, say /system/xbin/post-boot (set exec perm)

  2. Add the above custom script path at the end of /system/etc/init.qcom.post_boot.sh

Eg:

# echo /system/xbin/post-boot >> /system/etc/init.qcom.post_boot.sh

Done!

(If you can't find the qcom post_boot (Qualcomm devices), look for any post_boot scripts)

2

I think that most easy way would be by using app Kernel Adiutor. It has ability to emulate init.d Open app and swipe from left edge, it will reveal menu, scroll to tools section and than tap on init.d There you have a switch to enable or disable init.d emulator, for devices that doesn't support init.d, in bottom right you have a "plus" icon to add scripts to run.

1
  • Good job suggesting KA. I tried it but didn't know what to do months ago.
    – iBug
    Aug 25, 2017 at 14:21
1

From my answer on another question, I have two methods here.

1. Add init.d support manually by editing init.rc

I haven't done this ever personally but I can tell that

  • You need to unpack and repack your boot image. This may not be very hard if you can learn from the SuperSU zip package.

2. Replace a system service (in this case, the script will always be run as root)

Replace a system service (debuggerd is the best choice) binary with your custom shell script. Then run start debuggerd to activate it (effective from next boot).

If there's a debuggerd64, be sure to replace it with a null script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .