About this thread
In this thread i will post my work on a init.d like support for stock rom which i call "Boot Script Utilities".
This work was developed for personal use and for my personal purposes.
If you do not like to use it please do not.
I am not responsible for whatever happens to your phone.
What is init.d?
Init.d is a folder located in "/system/etc/init.d/", but not all roms have his folder (stock rom don't have the folder).
What is special with this folder is that any script inside this folder will run on phone boot.
Why to run scripts on boot?
On boot many system variables are initiated before any application run, so you can make automatic tweaks on every boot.
ex. Swap external storage to internal.
Boot Script Utilities on stock Samsung Galaxy Core
This was developed for personal use. This is not the original init.d support.
I developed a similar support in order to implement some more features.
This do not means that this is a better way to roon scripts on boot.
What do i need?
A rooted Samsung Galaxy Core (I used I8260, for how to root search the forum)
A good root explorer (well Root Explorer worked)
A recovery with backup/restore support (to backup your rom in case you soft brick your phone)
What we will do?
We will edit a system file to run a script i wrote. This script will run all scripts (or not all read more below) inside /system/etc/init.d/ folder.
Step 0 - Backup your rom
Boot into your recovery and make a backup.
Step 1 - init.d folder
Create a directory on "/system/etc/" and name it "init.d".
So now directory "/system/etc/init.d/" exist.
Step 2 - Boot Script Utilities main script
Copy "init.bsu.boot.sh" file (link on the end of the post) in "/system/etc/".
So now file "/system/etc/init.bsu.boot.sh" exist.
Step 3 - Edit system file, run Boot Script Utilities
The system file we will edit is "/system/etc/init.qcom.post_boot.sh"
Insert this code on the bottom of the script
# Run Boot Script Utilities # For galaxy core stock rom # by DarkThanos /system/bin/sh /system/etc/init.bsu.boot.sh > /data/tmp/init.bsu.log 2>&1 &
Insert your scripts inside "/system/etc/init.d/" and whey will run on boot.
Boot Script Utilities features
Disable all scripts
If file "/system/etc/init.d/disabled" exist no script will run.
Any script named like "*.disabled" or "*.disabled.sh" will not run.
ex. "/system/etc/init.d/testscript.disabled.sh" will not run.
Run scripts asynchronous
Any script named like "*.async" or "*.async.sh" will run asynchronous.
ex. "/system/etc/init.d/testscript.async.sh" will run asynchronous.
Scripts run order
Scripts run in name order.
Log on every boot
All scripts results-errors output (stdout/stderr) will be printed on "/data/tmp/init.bsu.log"
- 1.0 Version
- Script Public for first time.
- init.d like support
- Script Public for first time.
It does not really matters from where the script is called.
The script first checks if boot is completed, if not it sleeps for 2 seconds.
(so you need to call the script after boot, or before but asynchronous)
# Get boot complete state isBootCompleted=`getprop dev.bootcomplete` # Wait For boot complete event # Probably useless unless script called from other file while [ "$isBootCompleted" -ne '1' ] do # Wait and check again sleep 2 # Check if boot completed isBootCompleted=`getprop dev.bootcomplete` done
If it do not exist, it will run all not disabled scripts inside "/system/etc/init.d/".
It will check every file inside and analyze its name so it knows if the script is disabled or asynchronous.
# Create a init.d Support # Implement /system/etc/init.d/ folder # Check if init.d is disabled # If /system/etc/init.d/disabled file exist, then init.d is disabled if [[ ! -f /system/etc/init.d/disabled ]] then echo "[$manager_name] Initiating init.d scripts" # Run every script on init.d folder for scriptfile in /system/etc/init.d/* do if test -f "$scriptfile" then # Get script name scriptname=$(basename $scriptfile) # Check if script is disabled # ex1 : 'testscript.sh.disabled' is disabled # ex1 : 'testscript.disabled.sh' is disabled echo "$scriptname" | grep -q -E '\.(disabled|disable\.sh)$' if [ $? -eq 0 ] then echo "[$manager_name] Script $scriptname is disabled" else # check if script is asynchronous # ex1 : 'testscript.sh.async' is asynchronous # ex2 : 'testscript.async.sh' is asynchronous echo "$scriptname" | grep -q -E '\.(async|async\.sh)$' if [ $? -eq 0 ] then echo "[$manager_name] Run Script $scriptname asynchronous" /system/bin/sh "$scriptfile" | script_log & else echo "[$manager_name] Run Script $scriptname" /system/bin/sh "$scriptfile" | script_log fi fi fi done else echo '[$manager_name] init.d is disabled' fi
Please suggest any fixes or any improvements by messaging me.
Thanks for your time.