Launch a script at boot

Hi there,

Do you know how to launch a script at boot on Android Nougat?

I used to create a 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 ‘’?


Yes I am. My 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
                seclabel u:r:tee:s0
+service myExecutable /system/bin/myExecutable
+        class main
+        user_root
+        group root
+        oneshot

2.Modify the file ‘device/khadas/kvim/’

@@ -37,6 +37,10 @@ PRODUCT_COPY_FILES += \
     device/khadas/kvim/files/mesondisplay.cfg:system/etc/mesondisplay.cfg \
+    device/khadas/kvim/file/myExecutable:system/bin/myExecutable

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 /system/etc/init.d/userinit
$ adb shell vi /system/bin/
$ adb sync 
$ adb reboot


  1. The file ‘’ must be renamed as ‘userinit’

  2. Modify the file ‘system/bin/’

@@ -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."
1 Like

In a Amlogic Tx3 tv-box, it works!!

Hiii @Terry

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.