RK3399 Android 添加开机启动shell脚本

按需求建了一个开机启动的脚本

1.建立myshell.sh脚本 ,放在device/rockchip/rk3399内

#!/system/bin/sh

//启动之后一直循环
while true;do 
        //对应操作
        sleep 1
   
done     

2.建立对应的myshell.te文件,放在device/rockchip/common/sepolicy内

device/rockchip/common/sepolicy/myshell.te 
type myshell, domain;
type myshell_exec, exec_type, file_type;


init_daemon_domain(myshell)

//添加对应功能的授权
allow myshell init_tmpfs:file create_file_perms;
allow myshell self:capability { dac_override net_admin net_raw setgid setuid };
allow myshell device:dir { open read };
allow myshell shell:lnk_file { read };
allow myshell rootfs:lnk_file { getattr };
allow myshell socket_device:sock_file { write };

allow myshell shell_exec:file { getattr read};
allow myshell fuse:dir { search write add_name getattr};
allow myshell fuse:file { create write open getattr};
allow myshell system_file:file { execute_no_trans};

avc权限添加 可参考:https://blog.csdn.net/tq501501/article/details/103556837

3. 添加到 system/core/rootdir/init.rc

service myshell /system/bin/myshell.sh
     user root
     group root
     disabled

#在init.rc中启动该服务
on property:sys.boot_completed=1
     start myshell

chown root shell /system/bin/myshell.sh
chmod 0550 /system/bin/myshell.sh

4.修改device/rockchip/common/sepolicy/file_contexts

 #add for glgps
 /system/bin/glgps    u:object_r:gpsd_exec:s0
+/system/bin/myshell.sh u:object_r:myshell_exec:s0

5.修改device/rockchip/rk3399/rk3399.mk  //添加脚本到板子的system/bin内

 PRODUCT_COPY_FILES += vendor/rockchip/common/phone/etc/apns-full-conf.xml:system/etc/apns-conf.xml
 PRODUCT_COPY_FILES += vendor/rockchip/common/phone/etc/spn-conf.xml:system/etc/spn-conf.xml
+PRODUCT_COPY_FILES += device/rockchip/rk3399/myshell.sh:system/bin/myshell.sh

6. 修改system/sepolicy/file_contexts

添加以下(注意此处不要加.sh)

/system/bin/myshell             u:object_r:myshell_exec:s0 

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
要在RK3568上添加开机启动shell脚本,你需要执行以下步骤: 1. 在系统的/bin目录下创建名为myshellshell脚本文件。你可以使用以下命令进行创建:`touch /system/bin/myshell` 2. 编辑init.rc文件,将以下内容添加到文件的末尾: ``` service myshell /system/bin/myshell.sh user root group root disabled on property:sys.boot_completed=1 start myshell ``` 这将在系统启动完成后执行myshell.sh脚本,并以root用户和root组的身份运行。 3. 在device/rockchip/common/sepolicy目录下创建名为myshell.te的文件,并将以下内容添加到文件中: ``` type myshell, domain; type myshell_exec, exec_type, file_type; init_daemon_domain(myshell) allow myshell init_tmpfs:file create_file_perms; allow myshell self:capability { dac_override net_admin net_raw setgid setuid }; allow myshell device:dir { open read }; allow myshell shell:lnk_file { read }; allow myshell rootfs:lnk_file { getattr }; allow myshell socket_device:sock_file { write }; allow myshell shell_exec:file { getattr read}; allow myshell fuse:dir { search write add_name getattr}; allow myshell fuse:file { create write open getattr}; allow myshell system_file:file { execute_no_trans}; ``` 这些规则会为myshell脚本提供必要的权限和访问控制。 请注意,这些步骤是基于提供的引用内容,具体实施可能会因系统环境和配置而有所不同。在进行任何修改前,请确保你对系统的了解和备份。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [RK3399 Android 添加开机启动shell脚本](https://blog.csdn.net/weixin_41720013/article/details/120034087)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值