• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Init.d for Oreo - root required

Search This thread

DarthJabba9

Senior Member
May 5, 2014
3,731
3,574
Greater London
I have created a mod (initd-DJ9) to add init.d functionality to Oreo ROMs.

Anyone who has added init.d to Nougat ROMs by patching "init.qcom.post_boot.sh" will have learnt that this does not work with Oreo.

The initd-DJ9 mod avoids that problem.

What use is init.d?
1. init.d allows you to fine-tune/tweak your device or fix problems, and to make the changes persistent (i.e., to survive reboots) without changing your ROM
2. Typical uses include: a) setting new cpu frequencies (overclock or underclock) to override the stock ones; b) tweak interactive governor values; c) disable/enable cpu cores; d) running fstrim on your device's storage; d) retrieve hardware information that is normally difficult to ascertain; e) tweak I/O values; f) set the brightness of led/torch; g) do certain things that you want to happen each time the phone is booted up, etc, etc. - see the sample script that is attached.

Downloads
1A initd-DJ9 installer: Generic (activated on boot_completed)
OR;
1B. initd-DJ9 installer: Snapdragon only (activated on completion of qcom post-boot)
2. Readme
3. Sample init.d script (updated)

Installation
1. Backup your current boot image - if case something goes wrong, you can restore it with TWRP/OrangeFox recovery
2. Download your preferred initd-DJ9 zip installer to your internal (or external) SD
3. Boot to recovery
4. Install it as a normal zip, from TWRP/OrangeFox (or any other) recovery (what the installer does is to patch the boot image's ramdisk, using anykernel2 functionality by @osm0sis)
5. You are ready to roll!

Usage (your phone must be rooted)
1. Install initd-DJ9
2. Create a shell script (it must have the extension ".sh", and must have unix/linux line endings - not Windows or Mac line endings) - see the attachment below for a sample (rename it to sample.sh)
3. Copy the shell script to /system/etc/init.d/
4. Reboot the phone. Every time that the phone is booted, the init.d script(s) will be executed.
5. Check "/data/local/sysinitd.log" to see whether the scripts were executed. This file is updated on every bootup, and so you might want to delete it once in a while , so that it doesn't get too big.
6. This mod has been tested on a number of Oreo ROMs. It has not been tested on Nougat ROMs. It uses anykernel2 functionality, and so might work on Nougat and other ROMs. However, I have only tested it on Oreo. I would not recommend using it on Nougat or Marshmallow ROMs. If you do, you are on your own!
 

Attachments

  • sample-sh.txt
    4.3 KB · Views: 337
Last edited:

thapaavijeet

Senior Member
Feb 25, 2018
199
88
Bangalore
Thank you for this.

One question though, is root required for your init.d mod to function or just to push the scripts and set the required permission.
I tried to figure it out by looking at the codes but I'm kinda noob to this.
 

DarthJabba9

Senior Member
May 5, 2014
3,731
3,574
Greater London
Thank you for this.

One question though, is root required for your init.d mod to function or just to push the scripts and set the required permission.
I tried to figure it out by looking at the codes but I'm kinda noob to this.
Note the "root required" in the title of the thread? Although it should be possible for the init.d process to kick in without root, you would definitely need to be rooted to use the feature. How would you create or edit your own initd scripts in the /system/etc/init.d/ directory without root?
 
Last edited:

thapaavijeet

Senior Member
Feb 25, 2018
199
88
Bangalore
Note the "root required" in the title of the thread? Although it should be possible for the init.d process to kick in without root, you would definitely need to be rooted to use the feature. How would you create or edit your own initd scripts in the /system/etc/init.d/ directory without root?

If you could include the directory creation in you mod, if not already there then placing scripts in it and chmod 775 on the script can be done though TWRP file manager itself.

The code should be something like this but I'm not sure about it. However, I was able to place scripts through custom recoveries on un rooted devices.

Code:
INITDIR=/system/etc/init.d

if [ ! -d $INITDIR ]; then
  mkdir -p $INITDIR
fi
 
Last edited:

jakson7474

Senior Member
Oct 13, 2014
147
37
Salvador
Can you correct me if this init.d script is right or wrong, if it is wrong how would it be right?


#!/system/bin/sh
# Cloudflare DNS
iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53
iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53
iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53
iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53

setprop net.eth0.dns1 1.1.1.1
setprop net.eth0.dns2 1.0.0.1

setprop net.dns1 1.1.1.1
setprop net.dns2 1.0.0.1

setprop net.ppp0.dns1 1.1.1.1
setprop net.ppp0.dns2 1.0.0.1

setprop net.rmnet0.dns1 1.1.1.1
setprop net.rmnet0.dns2 1.0.0.1

setprop net.rmnet1.dns1 1.1.1.1
setprop net.rmnet1.dns2 1.0.0.1

setprop net.pdpbr1.dns1 1.1.1.1
setprop net.pdpbr1.dns2 1.0.0.1

setprop 2606:4700:4700::1111
setprop 2606:4700:4700::1001
 

Attachments

  • Screenshot_Arquivos_20180806-031620.jpg
    Screenshot_Arquivos_20180806-031620.jpg
    96.9 KB · Views: 254

coolpixs4

Senior Member
Mar 7, 2011
525
140
I have created a mod (initd-DJ9) to add init.d functionality to Oreo ROMs.

Anyone who has added init.d to Nougat ROMs by patching "init.qcom.post_boot.sh" will have learnt that this does not work with Oreo.

The initd-DJ9 mod avoids that problem.

What use is init.d?
1. init.d allows you to fine-tune/tweak your device or fix problems, and to make the changes persistent (i.e., to survive reboots) without changing your ROM
2. Typical uses include: a) setting new cpu frequencies (overclock or underclock) to override the stock ones; b) tweak interactive governor values; c) disable/enable cpu cores; d) running fstrim on your device's storage; d) retrieve hardware information that is normally difficult to ascertain; e) tweak I/O values; f) set the brightness of led/torch; g) do certain things that you want to happen each time the phone is booted up, etc, etc. - see the sample script that is attached.

Downloads
1A initd-DJ9 installer: Generic (activated on boot_completed)
OR;
1B. initd-DJ9 installer: Snapdragon only (activated on completion of qcom post-boot)
2. Readme
3. Sample init.d script (updated)

Installation
1. Backup your current boot image - if case something goes wrong, you can restore it with TWRP/OrangeFox recovery
2. Download your preferred initd-DJ9 zip installer to your internal (or external) SD
3. Boot to recovery
4. Install it as a normal zip, from TWRP/OrangeFox (or any other) recovery (what the installer does is to patch the boot image's ramdisk, using anykernel2 functionality by @osm0sis)
5. You are ready to roll!

Usage (your phone must be rooted)
1. Install initd-DJ9
2. Create a shell script (it must have the extension ".sh", and must have unix/linux line endings - not Windows or Mac line endings) - see the attachment below for a sample (rename it to sample.sh)
3. Copy the shell script to /system/etc/init.d/
4. Reboot the phone. Every time that the phone is booted, the init.d script(s) will be executed.
5. Check "/data/local/sysinitd.log" to see whether the scripts were executed. This file is updated on every bootup, and so you might want to delete it once in a while , so that it doesn't get too big.
6. This mod has been tested on a number of Oreo ROMs. It has not been tested on Nougat ROMs. It uses anykernel2 functionality, and so might work on Nougat and other ROMs. However, I have only tested it on Oreo. I would not recommend using it on Nougat or Marshmallow ROMs. If you do, you are on your own!
-------
Thank you,
finally, I drop here and found a solution to enable init.d for Mido SND (stock kernel-Android N)
Try a lot solutions around but seem not to work (cann't find /data/init_test.log), even the solution to put scripts in magisk/.core/post-fs-data.d,...etc

until this zip (patch boot.img) is working for me
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    I have created a mod (initd-DJ9) to add init.d functionality to Oreo ROMs.

    Anyone who has added init.d to Nougat ROMs by patching "init.qcom.post_boot.sh" will have learnt that this does not work with Oreo.

    The initd-DJ9 mod avoids that problem.

    What use is init.d?
    1. init.d allows you to fine-tune/tweak your device or fix problems, and to make the changes persistent (i.e., to survive reboots) without changing your ROM
    2. Typical uses include: a) setting new cpu frequencies (overclock or underclock) to override the stock ones; b) tweak interactive governor values; c) disable/enable cpu cores; d) running fstrim on your device's storage; d) retrieve hardware information that is normally difficult to ascertain; e) tweak I/O values; f) set the brightness of led/torch; g) do certain things that you want to happen each time the phone is booted up, etc, etc. - see the sample script that is attached.

    Downloads
    1A initd-DJ9 installer: Generic (activated on boot_completed)
    OR;
    1B. initd-DJ9 installer: Snapdragon only (activated on completion of qcom post-boot)
    2. Readme
    3. Sample init.d script (updated)

    Installation
    1. Backup your current boot image - if case something goes wrong, you can restore it with TWRP/OrangeFox recovery
    2. Download your preferred initd-DJ9 zip installer to your internal (or external) SD
    3. Boot to recovery
    4. Install it as a normal zip, from TWRP/OrangeFox (or any other) recovery (what the installer does is to patch the boot image's ramdisk, using anykernel2 functionality by @osm0sis)
    5. You are ready to roll!

    Usage (your phone must be rooted)
    1. Install initd-DJ9
    2. Create a shell script (it must have the extension ".sh", and must have unix/linux line endings - not Windows or Mac line endings) - see the attachment below for a sample (rename it to sample.sh)
    3. Copy the shell script to /system/etc/init.d/
    4. Reboot the phone. Every time that the phone is booted, the init.d script(s) will be executed.
    5. Check "/data/local/sysinitd.log" to see whether the scripts were executed. This file is updated on every bootup, and so you might want to delete it once in a while , so that it doesn't get too big.
    6. This mod has been tested on a number of Oreo ROMs. It has not been tested on Nougat ROMs. It uses anykernel2 functionality, and so might work on Nougat and other ROMs. However, I have only tested it on Oreo. I would not recommend using it on Nougat or Marshmallow ROMs. If you do, you are on your own!
    1
    Sample script say 'echo "0" > /proc/touchpanel/enable_dt2w' (disable double-tap-to-wake). You echo "1" to enable?
    All you need to do is to delete the line, or comment it out.
    1
    If you could include the directory creation in you mod, if not already there then placing scripts in it and chmod 775 on the script can be done though TWRP file manager itself.
    All that is already there.