0

i have problem when i want to run my service on init.rc

and here is my example code

on property:sys.boot_completed=1
   start myservice

service myservice /etc/myscript.sh
    class main
    user root
    oneshot

but after device boot i have found log

init: myservice does not have a SELinux domain defined

please give me some example how to correct this problem

my script are working on android 6.0

and not run since android 8.0 or greater

  • You need to put seclabel in service options. See this answer for example. – Irfan Latif Feb 15 at 2:25
  • im already try put seclabel for example seclabel u:r:init:s0 but i dont know how to use i got log exited 0 after executed , your example answer its too complicated to me , it hink i need just simple sample code how to give name to my seclabel and call methood – sheth Feb 15 at 3:02
  • Can you share the contents of your script? You'll get exited for a shell script. Is your phone rooted? If yes, how did you root it? Is SELinux in enforcing mode? – Irfan Latif Feb 15 at 7:20
  • yes my phone is rooted with magisk last version 1.81 , my script content #!/system/bin/sh echo 512,1024,1280,2048,3072,4096 > /sys/module/lowmemorykiller/parameters/minfree echo 70 > /proc/sys/vm/dirty_background_ratio echo 90 > /proc/sys/vm/dirty_ratio echo 10 > /proc/sys/vm/vfs_cache_pressure echo 1 > /proc/sys/vm/oom_kill_allocating_task sleep 20 swapon /dev/block/mmcblk1p2 echo 60> /proc/sys/vm/swappiness – sheth Feb 15 at 7:56
  • The script will exit after writing kernel parameters and the service will have stopped status. Also add disabled option to service so that it isn't executed before boot_completed. If init context isn't allowed to access your script or the files mentioned in it, use seclabel u:r:magisk:s0 which is allowed to access everything on device. Or you can define your own context and/or rules. What else you expect from this service? – Irfan Latif Feb 15 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.