RK3399 开机自启一个shell脚本,一直起不来BUG

news/2024/10/18 1:38:10/

开机自启shell脚本如下:

diff --git a/device/rockchip/common/sepolicy/file_contexts b/device/rockchip/common/sepolicy/file_contexts
index eb6b5e4bb4..0bbe781a7c 100755
--- a/device/rockchip/common/sepolicy/file_contexts
+++ b/device/rockchip/common/sepolicy/file_contexts
@@ -165,3 +165,4 @@/system/vendor/bin/camera_test   u:object_r:camera_test_exec:s0/system/bin/xone-agent u:object_r:xone-agent_exec:s0
+/system/bin/myshell.sh u:object_r:myshell_exec:s0
diff --git a/device/rockchip/common/sepolicy/myshell.te b/device/rockchip/common/sepolicy/myshell.te
new file mode 100644
index 0000000000..11fc663901
--- /dev/null
+++ b/device/rockchip/common/sepolicy/myshell.te
@@ -0,0 +1,18 @@
+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};
+permissive myshell;diff --git a/device/rockchip/rk3399/init.rk3399.rc b/device/rockchip/rk3399/init.rk3399.rc
index 805ce6f79e..743e6d3aa2 100755
--- a/device/rockchip/rk3399/init.rk3399.rc
+++ b/device/rockchip/rk3399/init.rk3399.rc
@@ -31,10 +31,18 @@ on bootchmod 0777 /system/bin/xone-agentstart xone-agent+    chown root shell /system/bin/myshell.sh
+    chmod 0777 /system/bin/myshell.sh
+    start myshell
+service xone-agent /system/bin/xone-agentuser rootgroup rootdisabledoneshot-
+service myshell /system/bin/myshell.sh
+    user root
+       group root
+       disabled
+       oneshot
diff --git a/device/rockchip/rk3399/myshell.sh b/device/rockchip/rk3399/myshell.sh
new file mode 100644
index 0000000000..c5505b6adc
--- /dev/null
+++ b/device/rockchip/rk3399/myshell.sh
@@ -0,0 +1,6 @@
+#!/system/bin/sh
+while [ true ] 
+do
+        echo "123"
+done
diff --git a/device/rockchip/rk3399/rk3399_all.mk b/device/rockchip/rk3399/rk3399_all.mk
index 8bbcdef3a3..db7136f077 100755
--- a/device/rockchip/rk3399/rk3399_all.mk
+++ b/device/rockchip/rk3399/rk3399_all.mk
@@ -103,6 +103,7 @@ PRODUCT_COPY_FILES += \device/rockchip/rk3399/rockchip_test/rockchip_test.sh:/system/bin/rockchip_test.shPRODUCT_COPY_FILES += \
+       device/rockchip/rk3399/myshell.sh:/system/bin/myshell.sh \device/rockchip/rk3399/top:/system/bin/top \device/rockchip/rk3399/xone-agent:/system/bin/xone-agent \device/rockchip/rk3399/xoneagent.sh:/system/bin/xoneagent.sh \
diff --git a/system/sepolicy/file_contexts b/system/sepolicy/file_contexts
index d64e67d29b..01e69da280 100644
--- a/system/sepolicy/file_contexts
+++ b/system/sepolicy/file_contexts
@@ -220,7 +220,7 @@/system/bin/update_engine        u:object_r:update_engine_exec:s0/system/bin/bspatch              u:object_r:update_engine_exec:s0/system/bin/selectrildlib      u:object_r:selectrildlib_exec:s0
-
+/system/bin/myshell             u:object_r:myshell_exec:s0 

然后就是死活起不来,但是和别人的是一模一样的,csdn都翻烂了,最后找到解决办法:

--- a/device/rockchip/rk3399/init.rk3399.rc
+++ b/device/rockchip/rk3399/init.rk3399.rc
@@ -33,7 +33,6 @@ on bootchown root shell /system/bin/myshell.shchmod 0777 /system/bin/myshell.sh
-    start myshellservice xone-agent /system/bin/xone-agentuser root
@@ -41,8 +40,12 @@ service xone-agent /system/bin/xone-agentdisabledoneshot-service myshell /system/bin/myshell.sh
-    user root
+service myshell /system/bin/sh /system/bin/myshell.sh
+       user rootgroup rootdisabledoneshot
+       seclabel u:r:shell:s0
+    
+on property:sys.boot_completed=1
+    start myshell

其实就是在service下面加上seclabel u:r:shell:s0就行了


http://www.ppmy.cn/news/1063074.html

相关文章

算法笔记:球树

1 KD树的问题 算法笔记:KD树_UQI-LIUWJ的博客-CSDN博客 在kd树中,导致性能下降的最核心因素是因为kd-tree中被分割的子空间是一个个的超方体,而求最近邻时使用的是欧式距离(超球)。超方体与超球体相交的可能性是极高…

深度学习4. 循环神经网络 – Recurrent Neural Network | RNN

目录 循环神经网络 – Recurrent Neural Network | RNN 为什么需要 RNN ?独特价值是什么? RNN 的基本原理 RNN 的优化算法 RNN 到 LSTM – 长短期记忆网络 从 LSTM 到 GRU RNN 的应用和使用场景 总结 百度百科维基百科 循环神经网络 – Recurre…

字节流概述,及字节流写数据的三种方式

1.IO流概述和分类 如果数据通过记事本打开,我们还可以读懂里面的内容就使用字符流,否则使用字节流。如果不知道使用哪种类型的流,就使用字节流。 2.字节流写数据 创建字节输出流的时候,一共做了三件事情。 调用系统功能创建了文…

国际版阿里云/腾讯云CDN装备运用教程:加快网站拜访速度

阿里云CDN装备运用教程:加快网站拜访速度 本文旨在为读者供给一个关于阿里云CDN的简要教程。咱们将介绍阿里云CDN的基本概念、资源加快过程、同步资源设置以及与阿里云OSS目标存储的结合。期望经过这篇教程,读者能够更好地了解和利用阿里云CDN服务&…

【80天学习完《深入理解计算机系统》】第十天 3.3 条件码寄存器【CF ZF SF OF】【set】

专注 效率 记忆 预习 笔记 复习 做题 欢迎观看我的博客,如有问题交流,欢迎评论区留言,一定尽快回复!(大家可以去看我的专栏,是所有文章的目录)   文章字体风格: 红色文字表示&#…

E. Nastya and Potions - 记忆化搜索

分析: dfs永远都需要记忆化搜索,也算是优化技巧吧,首先不知道哪种方法更加好,本质就是找每种材料的最小费用,能通过几种费用更少的材料代替就可以将费用优化成更小,这也就需要dfs来找最小费用,但…

单片机学习-蜂鸣器电子元件

蜂鸣器是有什么作用的? 蜂鸣器 是 一种 一体化结构 的电子训响器,可以发出声音的电子元器件 蜂鸣器分类? ①压电式蜂鸣器(图左) 称: 无源蜂鸣器 ②电磁式蜂鸣器(图右) 称&#xf…

Docker 容器学习笔记

Docker 容器学习笔记 容器的由来 早先,虚拟机通过操作系统实现相互隔离,保证应用程序在运行时相互独立,避免相互干扰。但是操作系统又笨又重,耗费资源严重: 容器技术只隔离应用程序的运行时环境但容器之间共享同一个…