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

开机自启shell脚本如下:

bash 复制代码
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 boot
     chmod 0777 /system/bin/xone-agent
     start xone-agent
 
+    chown root shell /system/bin/myshell.sh
+    chmod 0777 /system/bin/myshell.sh
+    start myshell
+
 service xone-agent /system/bin/xone-agent
        user root
        group root
        disabled
        oneshot
 
-
+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.sh
 
 PRODUCT_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都翻烂了,最后找到解决办法:

bash 复制代码
--- a/device/rockchip/rk3399/init.rk3399.rc
+++ b/device/rockchip/rk3399/init.rk3399.rc
@@ -33,7 +33,6 @@ on boot
 
     chown root shell /system/bin/myshell.sh
     chmod 0777 /system/bin/myshell.sh
-    start myshell
 
 service xone-agent /system/bin/xone-agent
        user root
@@ -41,8 +40,12 @@ service xone-agent /system/bin/xone-agent
        disabled
        oneshot
 
-service myshell /system/bin/myshell.sh
-    user root
+service myshell /system/bin/sh /system/bin/myshell.sh
+       user root
        group root
        disabled
        oneshot
+       seclabel u:r:shell:s0
+    
+on property:sys.boot_completed=1
+    start myshell

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

相关推荐
克莱因3582 小时前
Linux CentOS7 进程基础知识
linux·运维·服务器
我爱学习好爱好爱5 小时前
Ansible 常用模块详解:yum、service/systemd、copy实战
linux·服务器·ansible
野生的码农5 小时前
放过自己,降低预期,及时行乐
android·ai编程
papaofdoudou5 小时前
LINUX VFIO被IOMMUFD取代
linux·运维·服务器
FreakStudio5 小时前
ESP32居然能当 DNS 服务器用?内含NCSI欺骗和DNS劫持实现
python·单片机·嵌入式·面向对象·并行计算·电子diy
拾光向日葵5 小时前
2026贵州高职专科报考全问答合集:专业、就业与实力大盘点
大数据·人工智能·物联网
huwuhang5 小时前
索尼PS3游戏合集【中文游戏】8.12T 1430个游戏+PS3模拟器
android·游戏·智能手机·游戏机·电视
平生不喜凡桃李6 小时前
浅谈 Linux 中 namespace 相关系统调用
java·linux·服务器
无忧智库6 小时前
智慧医院的“新基建”:从顶层设计到全栈式智能运维的深度解构(PPT)
大数据·运维
YMWM_6 小时前
【问题】thor上的cubLas
linux·python·thor