简体   繁体   English

如何让init.d中的脚本在Android中启动时执行?

[英]How to get a script in init.d to execute on boot in Android?

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. 我的Android应用程序功能的一部分,它放置我在init.d中编写的脚本,以便它将在每次启动时执行。 (obviously my app is for root users only) (显然我的应用只适用于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. 我意识到这不是发布这个问题的最合适的地方,但我已经意识到这个社区对这些问题非常了解。

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. Android中没有update-rc.d ,因为它也没有SYSV init。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM