I have a script I need to run once, and only once the phone is booted.
I have attempted init.qcom.post_boot.sh, init.sec.boot.sh, debuggerd, and finally mkshrc
While my script ran with debuggerd, I found that it ran every time debuggerd ran, which is not something I need to happen... thus when I stumbled upon /system/etc/mkshrc
(the other 2 simply did not work)
What I found was, the script runs that one time, on boot... however, it also seems to run every time adb shell
runs, along with (I assume) everytime shell is fired up... which is also undersireable.
So, what can I do in /system/etc/mkshrc
to ensure my call to my script runs only the one time... at boot?
I thought about running a while
loop to check for the getprop sys.boot_completed
if it ==
1 then dump a file somewhere, and through an if
statement inside the looop to check for that file, if exists then exit, if not then run the next command... however, everywhere I am allowed to dump that file, it persists between boots, so that next command
never runs again.
NOTE Does not need root to do this, nor does my script need root to run (yes, I have confirmed)
CODE
BB=/system/xbin/busybox
MYPID=/mnt/sdcard/.kev-run
while [ `getprop init.svc.bootanim` == "stopped" ] ; do
# if the run file does not exist, and we are stopped
if [ ! -e $MYPID ]; then
# run the scripts, then create the run file
LOG=/mnt/sdcard/Download/kevs-scripts.log
$BB rm -f $LOG;
$BB echo "Launching Kevs Scripts" >> $LOG;
MY_SCRIPT
# write the run file so we aren't running this everytime this file runs
touch $MYPID;
sleep 1;
fi
done
# if we are still booting, delete the run file
while [ `getprop init.svc.bootanim` != "stopped" ] ; do
# we're not done booting, remove our makeshift pid file and sleep a second
$BB rm -f $MYPID;
sleep 1;
done
Seems to be off to me
debuggerd
again, and utilizingsetprop
to set a non-persistent "flag" now – Kevin Mar 01 '18 at 16:02/system/etc/init.d/
support is a CM(IIRC?) addition. Patchinginit.rc
seems to be the generally correct solution. In general,service …\n\tdisabled\n\toneshot
seems to work; don’t forget tochmod +x
it and copy to the correct partition beforehand. – mirabilos Mar 01 '18 at 20:14setprop
but what I'm finding now, is onceroot
is removed,setprop
no longer works.My goal is to get some tweaks to work without having to root. I have confirmed that some do indeed work, while some dont (which is expected), but the trick is getting them to fire off on boot... once :)
– Kevin Mar 02 '18 at 13:02debuggerd
throws a permission denied, so I think what I need to do is figure out the proper ownership, sepolicy, and context for it in order to get the permissions right... almost there LOL – Kevin Mar 02 '18 at 13:48