Do you know how to launch a script at boot on Android Nougat?
I used to create a userinit.sh script in /data/local on other boards but it doesn’t work for the Khadas VIM.
I’ve also tried to put my script in /etc/init.d but it didn’t work as well.
Are you a developer? Can you build your rom?
You need to modify the source code and execute the shell script.
What’s the function of your script ‘userinit.sh’?
Yes I am. My userinit.sh launches an executable from /data/local.
Here is its content:
I’ve gave the file all permissions.
chmod 0777 /data/local/myExecutable
You can follow below steps to have a try
1.Modify the file device/khadas/kvim/init.amlogic.board.rc
@@ -43,3 +43,8 @@ service tee_supplicant /system/bin/tee-supplicant
+service myExecutable /system/bin/myExecutable
+ class main
+ group root
2.Modify the file ‘device/khadas/kvim/device.mk’
@@ -37,6 +37,10 @@ PRODUCT_COPY_FILES += \
+PRODUCT_COPY_FILES += \
3.Copy the file ‘myExecutable’ to the path ‘device/khadas/kvim/file/’
4.Rebuild your rom
About how to add support for the script in the path ‘system/etc/init.d/’ , You can follow below method to test by adb command.
$ adb root
$ adb remount
$ adb push userinit.sh /system/etc/init.d/userinit
$ adb shell vi /system/bin/preinstall.sh
$ adb sync
$ adb reboot
The file ‘userinit.sh’ must be renamed as ‘userinit’
Modify the file ‘system/bin/preinstall.sh’
@@ -3,6 +3,7 @@
+busybox run-parts /system/etc/init.d/
if [ ! -e $MARK ]; then
echo "booting the first time, so pre-install some APKs."
In a Amlogic Tx3 tv-box, it works!!
I am creating my own service for VIM3. Will I have to create .te file in sepolicy??
Or these three steps are enough??
I have done it.
Though I had to made few changes apart from those three steps suggested by Terry.
I also use VIM3.
Does the sepolicy folder need to modify ?
ex : *.te
path : \device\khadas\common\sepolicy
Yes, You have to modify sepolicy folder.