I want to run a conditional script commands during boot-up and the place to add it looks like better in init.rc or init.xxx.rc, where xxx stands for a platform name. init files have their own language and thus don't take conditional script language. Instead of directly putting those commands inside an init file, I wrote those commands in a seperate script file and call it as an service in init.rc.
(1) gemtek_prop_check.sh
#!/system/bin/sh
if [ -f /data/gemtek.prop ]
then
/system/busybox/bin/echo "gemtek.prop found!"
else
/system/busybox/bin/cp /gemtek_default.prop /data/gemtek.prop
/system/busybox/bin/chmod 666 /data/gemtek.prop
/system/busybox/bin/echo "gemtek.prop is re-generated!"
fi
- must contain #!/system/bin/sh
- must use absolute path
(2) init.rc
service console /system/bin/sh
class core
console
disabled
user root
group log
service gtk_prop_check /gemtek_prop_check.sh
class core
oneshot
- don't really know if the sequence matters, but I put it behind console service anyway.
(3) build/tools/post_process_props.py
Where a custom prop file can be added. In my case, gemtek_default.prop is added.
(4) build/core/build/core/Makefile
Where give the command to generate gemtek_default.prop
Reference links
http://blog.csdn.net/silvervi/article/details/6315888
https://github.com/android/platform_system_core/blob/master/init/readme.txt
沒有留言:
張貼留言