Root IS required !!
This mod will add init.d support to any rom even stock roms without editing the ramdisk. Instead it uses the post_boot.sh file that is in most if not all roms. It should work on most devices, if it does not work on yours please look in /system/etc and post the name of the file that contains "post_boot.sh".
This mod has been tested on the OneX and OneS.
To use just flash in recovery and add your favorite scripts to init.d.
For devs:
To add this method to your rom simply edit the post_boot.sh file and add this line at the bottom:
Code:
/system/etc/init.d/*
Easy right ? Suprised it hasn't been done before, well at least that i know of.
All files in init.d will be executed at boot just like regular init.d. You can also manually add the line and make it whatever directory you want.
Download:
http://goo.im/devs/smokin1337/Mods/EZ-InitD.zip
reserved.....
I did something similar to the Garminfone to give it init.d support. One question, have you considered using the runparts command (in busybox I believe) to execute the scripts. That is the standard way of doing it. You can also use logwrapper to have it output to logcat.
I want to add custom minfree values at boot, but init.d doesn't execute the script. init.d is working and other scripts (test ones) works, but they execute in /data. Minfree executes in /system. Would that matter?
Bump!
le : I installed minfree manager and tick 'set on boot'. The script in init.d was created but never executed. What happens?
REFERENCE
Read everything. Everything in this thread is important to make init.d script.
I am not responsible for anything that happens to your phone.
****************************************************************
***************************************************
We have come accross this quite a few times. So what is init.d folder?
In simple words, whatever scripts you place in this folder will be executed when the device boots.
******************************************************************************************************
ORDER in which scripts are executed.
Init.d scripts are executed in alphabetical order. That is, any script, the name of which starts with the alphabet A, will be executed first and scripts, the name of which starts with Z will be executed at last.
Therefore the name of the script is really important.
For example, if we make a script with name A, to change the governor to smartassv2
AND
we make another script with the name Z , to change the governor to PegasusQ and place both of them in init.d folder, then the system will first execute script A and change the governor to smartassv2, and then it will execute script Z and change the governor to PegasusQ.
So if you use any mod by some other person, and if you don't know what's inside the script then you should name your script with alphabet z to make your settings stick.
*********************************************************************************************************************************************************
OK NOW enough of explanations, Let's see how to make an init.d script.
REQUIREMENTS :-
1. ROOTED PHONE
2. BUSYBOX INSTALLED
3. KERNEL THAT SUPPORTS INIT.D (like CoCore)
4. TEXT EDITOR.
I usually use solid explorer to do every thing. If you are editing on your computer, then use notepad++.
STEP 1
Set up init.d folder. Using your root explorer, browse to /system/etc and create a folder init.d. Now set the folder's permission to rwxrwxrwx or 0777. You can do this with TWRP recovery also.
STEP 2
1. Now this is the real part. Create a file with appropriate name (see above if you have not read).
Remember, the script should not have any extentions like .txt or .sh. There should be no extentions.
2. Long press the file using your root explorer and open the file as text.
3. NOW THE FIRST LINE OF YOUR SCRIPT SHOULD ALWAYS BE
Code:
#!/system/bin/sh
Do not leave any blank space in between or after the line. As soon as you write this, press enter to go to the next line.
4. Now write any script that you want. For example, if you want to change the governor to smartassv2, then you need to use echo command, followed by the name of the governor followed by the path of the file that needs to be changed like this
Code:
echo "smartassv2" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
your script should look like this,
Code:
#!/system/bin/sh
echo "smartassv2" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
To set deep sleep to 4 script should be,
Code:
#!/system/bin/sh
echo "4" > /d/cpuidle/deepest_state
STEP 4
Put this file inside init.d folder. Now long press the file using your root explorer and set the permission to 0777 and ownership to root 0 : root 0.
Reboot your device.
*************************************************** *************************************************** ***************************************************
THINGS TO REMEMBER :-
1. NEVER leave a blank space at end of any line otherwise the script won't work.
2. To know about more tweaks go to the cocore thread and see the second and third posts.
http://forum.xda-developers.com/showthread.php?p=37782495
3. Download amd install script manager. Run the script through it. If it shows 0, then it means your script has no errors. If it returns any other number, it means the script has errors. (may be you left a blank space).
4. You can also tweak your governors. Read this thread to know various governor tweaks.
http://forum.xda-developers.com/showthread.php?t=1369817
*************************************************** *************************************************** ***************************************************
RESERVED
Definitely useful. Thanks a lot..
Thanks for this tutorial !!!
Sent from my GT-I9070 using xda app-developers app
Good
:good::good: thank you, very helpful
anantttt said:
REFERENCE
Read everything. Everything in this thread is important to make init.d script.
I am not responsible for anything that happens to your phone.
****************************************************************
***************************************************
We have come accross this quite a few times. So what is init.d folder?
In simple words, whatever scripts you place in this folder will be executed when the device boots.
******************************************************************************************************
ORDER in which scripts are executed.
Init.d scripts are executed in alphabetical order. That is, any script, the name of which starts with the alphabet A, will be executed first and scripts, the name of which starts with Z will be executed at last.
Therefore the name of the script is really important.
For example, if we make a script with name A, to change the governor to smartassv2
AND
we make another script with the name Z , to change the governor to PegasusQ and place both of them in init.d folder, then the system will first execute script A and change the governor to smartassv2, and then it will execute script Z and change the governor to PegasusQ.
So if you use any mod by some other person, and if you don't know what's inside the script then you should name your script with alphabet z to make your settings stick.
*********************************************************************************************************************************************************
OK NOW enough of explanations, Let's see how to make an init.d script.
REQUIREMENTS :-
1. ROOTED PHONE
2. BUSYBOX INSTALLED
3. KERNEL THAT SUPPORTS INIT.D (like CoCore)
4. TEXT EDITOR.
I usually use solid explorer to do every thing. If you are editing on your computer, then use notepad++.
STEP 1
Set up init.d folder. Using your root explorer, browse to /system/etc and create a folder init.d. Now set the folder's permission to rwxrwxrwx or 0777. You can do this with TWRP recovery also.
STEP 2
1. Now this is the real part. Create a file with appropriate name (see above if you have not read).
Remember, the script should not have any extentions like .txt or .sh. There should be no extentions.
2. Long press the file using your root explorer and open the file as text.
3. NOW THE FIRST LINE OF YOUR SCRIPT SHOULD ALWAYS BE
Do not leave any blank space in between or after the line. As soon as you write this, press enter to go to the next line.
4. Now write any script that you want. For example, if you want to change the governor to smartassv2, then you need to use echo command, followed by the name of the governor followed by the path of the file that needs to be changed like this
your script should look like this,
To set deep sleep to 4 script should be,
STEP 4
Put this file inside init.d folder. Now long press the file using your root explorer and set the permission to 0777 and ownership to root 0 : root 0.
Reboot your device.
*************************************************** *************************************************** ***************************************************
THINGS TO REMEMBER :-
1. NEVER leave a blank space at end of any line otherwise the script won't work.
2. To know about more tweaks go to the cocore thread and see the second and third posts.
http://forum.xda-developers.com/showthread.php?p=37782495
3. Download amd install script manager. Run the script through it. If it shows 0, then it means your script has no errors. If it returns any other number, it means the script has errors. (may be you left a blank space).
4. You can also tweak your governors. Read this thread to know various governor tweaks.
http://forum.xda-developers.com/showthread.php?t=1369817
*************************************************** *************************************************** ***************************************************
Click to expand...
Click to collapse
I'm having a bit of trouble trying to figure out how into save a script for init.d..
Do I save it as a .sh script?
If you take a look at Step 2 you can read this:
"Remember, the script should not have any extentions like .txt or .sh. There should be no extentions."
:good
Those commands only changes a specific parameter, what if you want to add something to ie. build.prop. Would you still use echo?
ie. echo "something" >> /system/build.prop
fusk said:
Those commands only changes a specific parameter, what if you want to add something to ie. build.prop. Would you still use echo?
ie. echo "something" >> /system/build.prop
Click to expand...
Click to collapse
Yes, we have to use echo to add something to build.prop but not at every boot...
The lines in the build.prop are still available after boot too..
So only once we have to do that....
If they changes i.e., the line exists but prop value changes then we have to use
Code:
setprop <prop>=<prop_value>
HemanthJabalpuri said:
Yes, we have to use echo to add something to build.prop but not at every boot...
The lines in the build.prop are still available after boot too..
So only once we have to do that....
If they changes i.e., the line exists but prop value changes then we have to use
Code:
setprop <prop>=<prop_value>
Click to expand...
Click to collapse
Thanks.
I had issues getting it to stick after reboot, the line i added disappeared every time. Wanted to try an init.d script and see if that did the trick. I havn't used it before so wanted to be sure about the command. But i does not appear to have worked.
Hey guys,
just got my device to run scripts put into /etc/init.d at startup and wanted to share my method with you.
First you need a script-tool from here on xda: http://forum.xda-developers.com/showthread.php?t=2055508
Thats actually doin all the magic so give the creator some credit - but just running it on your freshly rooted N3 might have some bad results. (you might lose root, at least partially - ill explain why)
So the su on the SELinux enabled devices like our note 3 has to be run as a daemon to work correctly. This is achieved by starting it through install-recovery.sh in /etc/. The init.d enable script (as far as I can tell by looking at the source) would just overwrite your install-recovery.sh and break root, plus in its "pure" form it doesnt work on the n3.
You can avoid these problems and make it actually work by editing your install-recovery.sh before running the script.
Its important you do this step before you apply the script, because it detects if the install-recovery.sh already has the required line and then does not overwrite if it finds it.
Ok here it goes - add the following line (preferably before the "/system/etc/install-recovery-2.sh" call:
Code:
/system/xbin/su -c /system/bin/sysinit system
This calls the /system/sysinit file (which is created by the script in the next step) as system user and a) prevents the overwrite of install-recovery.sh and b) makes it work by calling it as system user - without this addition by just calling /system/bin/sysinit the scripts would not run, or at least not with the required rights.
After you edited your install-recovery.sh you can run the script. (as root obviously)
Reboot and look into /data/log/ for init.d-log.txt or smth. If its there the scripts run, if not report back.
(when it didnt work on my phone at first I tried chaning the paths of the 99test script which is also created inside the init.d folder by the script, so that it would put the files on the sd card instead - to see if it was a writing permission problem or something, but it didnt help so i tried to run it trough "su system" and then it did - but I havent tried chaning back the 99test - so im not sure if this actually creates the init.d-log.txt inside the /data/log folder or if there are still permission problems... but at least the scripts do run hehe)
I have been try to flash initmd scripts but its not working it is not getting pushed to my init.d folder and if I manually push them into init.d also not executing checked with terminal?