Linux 如何在 init.d 中获取脚本以在 Android 启动时执行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5464713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get a script in init.d to execute on boot in Android?
提问by Frank Bozzo
Part of my android app's functionality it to place a script I have written in init.d, so that it will be executed on every startup. (obviously my app is for root users only)
我的 android 应用程序的一部分功能是放置我在 init.d 中编写的脚本,以便它在每次启动时执行。(显然我的应用程序仅适用于 root 用户)
Here's what I am doing:
这是我在做什么:
busybox mount -o rw,remount /system"
busybox cp -f /sdcard/*******/script /system/etc/init.d/script
busybox chmod +x /etc/init.d/script
update-rc.d script 99
The "update-rc.d script 99" line is where I run into trouble, it fails with an "update-rc.d not found" error.
“update-rc.d script 99”行是我遇到麻烦的地方,它因“update-rc.d not found”错误而失败。
Does anyone know what the proper command would be to make this work in Android??
有谁知道在 Android 中进行这项工作的正确命令是什么?
I realize that this isn't exactly the most appropriate place to post this question, but I have come realize that this community is extremely knowledgeable on these matters.
我意识到这并不是发布这个问题的最合适的地方,但我已经意识到这个社区对这些问题非常了解。
采纳答案by Diego Torres Milano
Add something like this to your init.rc
将这样的内容添加到您的 init.rc
service script /system/etc/init.d/script
oneshot
There's no update-rc.d
in Android because there's no SYSV init either.
update-rc.d
Android 中没有,因为也没有 SYSV init。