我有一个需求,我需要读取一个接口(比如/sys/module/my_file/parameters/val),然后根据它的值在另一个接口上写一些值。这必须在安卓文件系统的init.rc中完成。
流程应该是这样的
if ( read /sys/module/my_file/parameters/val == "yes") then
write /sys/devices/platform/target_file/val 100
有人能帮我做同样的事吗??有可能吗??
发布于 2012-09-04 09:18:52
您可以使用exec节来实现这一点:
exec <path> [ <argument> ]*
Fork and execute a program (<path>). This will block until
the program completes execution. It is best to avoid exec
as unlike the builtin commands, it runs the risk of getting
init "stuck".
详情请参见https://github.com/android/platform_system_core/blob/master/init/readme.txt。
示例:将代码移动到脚本(my_script.sh)中。将此代码添加到您的init.rc
on boot:
...
exec /path/to/my_script.sh
发布于 2016-10-26 12:18:26
您可以使用init的服务概念来运行脚本。下面是初始化script.rc文件的代码示例。
chmod 0750 /system/bin/myscript.sh
start script
[...]
service script /system/bin/myscript.sh
class main
user root
group root
oneshot
https://stackoverflow.com/questions/10734011
复制相似问题