Copy a shell script to android out folder and execute it during boot

痴心易碎 提交于 2020-01-07 05:08:27

问题


I have a shell script which I need to copy to anywhere in out folder during Android build process so that it appears somewhere in Android RootFS. Now, once it is copied after Android build process and becomes part of Android RootFS, I want to execute the shell script during boot time.

How can I do it?


回答1:


Well, I created a root folder in AOSP or anywhere, then created Android.mk and copied the script to be copied to out folder. Added below comments in Android.mk

$(shell cp -rf $(LOCAL_PATH)/myscript.sh `pwd`/$(TARGET_OUT)/path/to/folder/)

Now to make it run during Android boot, I added below code in last of init.goldfish.rc:

service myscript_start /system/bin/busybox ash /system/path/to/folder/myscript.sh
    class main
    oneshot

Also, I added below line under # start essential services section of init.goldfish.rc

start myscript_start

That way my script was copied to desired location of out folder and also got called during android boot time.

I wonder if there is any better way to do that. I would like to know if anyone has suggestions.



来源:https://stackoverflow.com/questions/14782156/copy-a-shell-script-to-android-out-folder-and-execute-it-during-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!