FORUMS

How to enable init.d to function in LineageOS 14.x (and later more?)

23 posts
Thanks Meter: 12
 
By ramast_, Junior Member on 29th June 2018, 02:15 PM
Post Reply Email Thread
I am using LineageOS 14 on my Galaxy S5 and while I do have the directory /system/etc/init.d , its scripts are not executed on startup as one would expect.
Searching different forums didn't lead to much beyond installing some random person's script with root permission or doing hacks.

I've invested sometime to get init.d work on my phone and wanted to share the how to with you:

Prerequisite:
Root access (shell) [ I am using addonsu-14.1-arm if that make a difference ]
LineageOS 14 (not tested on other versions but should work)

Steps:

1. mount your system partition as read/write
Code:
mount -oremount,rw /system
2. go to init directory
Code:
 cd /system/etc/init/
3. create file init_d.rc with following content
Code:
service init_d /system/bin/sh /system/bin/sysinit
    user root
    group root
    disabled
    oneshot
    seclabel u:r:sudaemon:s0

on property:sys.boot_completed=1 && property:sys.logbootcomplete=1
    start init_d
That's it.

Explanation:

/system/etc/init/ is android's version of linux's init.d but it have very different syntax and restricted set of commands.

the file init_d define a service called init_d which basically execute sysinit script (the script responsible for running /etc/init.d/ scripts).

the service is set to be disabled so it won't run by default. Finally I say that when the system finish booting start the service. the oneshot keyword is important because without the system will keep executing sysinit each time it exit.

the seclabel define SELinux label for this service, this one should give it full access
The Following 4 Users Say Thank You to ramast_ For This Useful Post: [ View ] Gift ramast_ Ad-Free
26th September 2018, 12:43 PM |#2  
Member
Flag Bangalore
Thanks Meter: 9
 
More
I tried this on a lineage 15.1 build and followed all steps , it did not work.
1st December 2018, 09:59 PM |#3  
Whammamoosha's Avatar
Member
Flag Rio de Janeiro
Thanks Meter: 23
 
Donate to Me
More
Worked like a charm!

I needed it to run swapon once (to free some unused RAM) without modifying any system files, only adding new ones, so system updates wouldn't overwrite the configuration.

Thank you very much!

Running LineageOS 15.1, 2018-11-30 nightly build on griffin (XT1650-3).

Quote:
Originally Posted by ramast_

I am using LineageOS 14 on my Galaxy S5 and while I do have the directory /system/etc/init.d , its scripts are not executed on startup as one would expect.
Searching different forums didn't lead to much beyond installing some random person's script with root permission or doing hacks.

I've invested sometime to get init.d work on my phone and wanted to share the how to with you:

Prerequisite:
Root access (shell) [ I am using addonsu-14.1-arm if that make a difference ]
LineageOS 14 (not tested on other versions but should work)

Steps:

1. mount your system partition as read/write

Code:
mount -oremount,rw /system
2. go to init directory
Code:
 cd /system/etc/init/
3. create file init_d.rc with following content
Code:
service init_d /system/bin/sh /system/bin/sysinit
    user root
    group root
    disabled
    oneshot
    seclabel u:r:sudaemon:s0

on property:sys.boot_completed=1 && property:sys.logbootcomplete=1
    start init_d
That's it.

Explanation:

/system/etc/init/ is android's version of linux's init.d but it have very different syntax and restricted set of commands.

the file init_d define a service called init_d which basically execute sysinit script (the script responsible for running /etc/init.d/ scripts).

the service is set to be disabled so it won't run by default. Finally I say that when the system finish booting start the service. the oneshot keyword is important because without the system will keep executing sysinit each time it exit.

the seclabel define SELinux label for this service, this one should give it full access

Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes