[MOD][SCRIPTS] Boot Script Utilities - Samsung Galaxy Core

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.
Click to expand...
Click to collapse
Just to be clear
I am not responsible for whatever happens to your phone.
Some Info
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.
Click to expand...
Click to collapse
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
Code:
# 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 &
Step 4 - Ready
Insert your scripts inside "/system/etc/init.d/" and whey will run on boot.
Click to expand...
Click to collapse
Boot Script Utilities features
Disable all scripts
If file "/system/etc/init.d/disabled" exist no script will run.
Disable scripts
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"
Click to expand...
Click to collapse
[Change log]
1.0 Version
Script Public for first time.
init.d like support
Click to expand...
Click to collapse
[Dev Doc]
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)
Code:
# 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
The next step is to check if "/system/etc/init.d/disabled" file exist.
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.
Code:
# 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
That's all.
Please suggest any fixes or any improvements by messaging me.
Thanks for your time.
Click to expand...
Click to collapse

All Scripts
Links to all scripts posts
Optimize apks using ZipAlign
Optimize SQlite databases of apps
Swap External SD with Internal SD
Click to expand...
Click to collapse

[Script][Swap External SD with Internal SD][v1.0]
Name : Swap External SD with Internal SD
Version : v1.0
Author : DarkThanos
Thanks to: codlab
Click to expand...
Click to collapse
This script wait for your external sd card to be mounted and swap it with internal if it is bigger.
One minute after boot it will stop waiting.
(Fastest swap method I found)
I am not responsible for whatever happens to your phone.
Tested on my Samsung Galaxy Core (I8260)
[Change log]
1.0 Version
Script Public for first time.
Swap internal sd with external (if external>internal)
Click to expand...
Click to collapse
[Dev Doc]
The script first creates 2 directories to mount external sd and internal sd,
so that it can distinguish them from each other ("/data/sd_cards/internal/", "/data/sd_cards/external/").
Code:
# Mount root rw
mount -o remount,rw /
# Create directory to mount sd cards
# Make directory to save cards
mkdir -p /data/sd_cards
# Make directory to save internal
mkdir -p /data/sd_cards/internal
# Make directory to save external
mkdir -p /data/sd_cards/external
In the next step, the script waits for an external sd to be mounted.
This wait time is the reason why the script is better to be asynchronous.
The script checks every 5 seconds for an external sd, but after 1 minute (12 tries) it stops.
Code:
# Wait for external sd card to be mounted
# Max wait time is 1 minute
maxWaitTime=60
# While external Sd Card has 0 Capacity
while [[ $(du -s /storage/extSdCard | awk '{print $1}') == "0" && $maxWaitTime>0 ]]
do
# Check again in 5 seconds
sleep 5
# Count down max wait time
maxWaitTime=maxWaitTime-5
done
As soon as an external sd is mounted, the script mounts the external sd on "/data/sd_cards/external/"
and the internal on "/data/sd_cards/internal/".
Code:
# Save mount points on folders
# Mount bind internal SD in folder /data/sd_cards/internal
mount -o bind /storage/sdcard0 /data/sd_cards/internal
# Mount bind external SD in folder /data/sd_cards/external
mount -t vfat -o rw,nosuid,nodev,noexec,relatime,user_id=1023,group_id=1023,default_permissions,allow_other /dev/block/vold/179:33 /data/sd_cards/external
So now the real internal sd can be found in the directory "/data/sd_cards/internal/"
and the real external sd can be found in the directory "/data/sd_cards/external/".
The reason we do this is to be able to make a script swap them again.
Then it checks the size of each, so that it knows if it ia worthing of swapping them.
Code:
# Get sd cards sizes
internalSdSize=$(du -s /storage/sdcard0 | awk '{print $1}')
externalSdSize=$(du -s /storage/extSdCard | awk '{print $1}')
If external sd is bigger, then on "/storage/sdcard0/" we mount "/data/sd_cards/external/"
and on "/storage/extSdCard/" we mount "/data/sd_cards/internal/".
Code:
# Swap sd cards
# If external sd card is bigger than internal swap
if [ $externalSdSize -gt $internalSdSize ]
then
# Swap
mount -o bind /data/sd_cards/internal /storage/extSdCard
mount -o bind /data/sd_cards/external /storage/sdcard0
fi
Click to expand...
Click to collapse

[Script][Optimize SQlite databases of apps][v1.0]
Name : Optimize SQlite databases of apps
Version : v1.0
Rewritten by : DarkThanos
Based on work of: pikachu01
Click to expand...
Click to collapse
This script optimize applications' database using sqlite3 (Vacuum/Reindex) every 5 boots or 5 days.
On any other boot it optimize only databases of phone, contacts, mms and settings .
Before use make a folder "libs" inside "/system/etc/init.d/",
insert the "sqlite3" file inside and give it execute permissions (the file is given with the script)
Bugs: (Its safe for use, its a warning not an error)
Contacts database is always locked, so can't be optimized.
I am not responsible for whatever happens to your phone.
Tested on my Samsung Galaxy Core (I8260)
[Change log]
1.0 Version
Script Public for first time.
SQlite databases on "/data/" optimize every 5 boots or 5 days.
SQlite databases of phone, contacts, mms and settings optimize on every boot.
Click to expand...
Click to collapse
[Dev Doc]
Script first initiate some variables
(path to Sqlite lib, path to a folder to save scripts data, minimum time between optimizes)
Code:
# Some variables
# SQLite path
sql_lib="/system/etc/init.d/libs/sqlite3";
# Data folder path
data_folder="/data/boot_scripts_data/";
# Data counter file name
data_file_counter="sql_optimize_counter";
# Data last run file name
data_file_lastrun="sql_optimize_lastrun";
# Max time between optimizes (in sec)
# 5 days = $(expr 5 \* 24 \* 60 \* 60 )
max_time_dif=432000
Check how many boots passed since last optimize
and when the last optimize was by reading scripts data.
Code:
# Create data folder if not exist
mkdir -p "$data_folder"
# Get data from files
# Run Counter
if [[ ! -f "$data_folder$data_file_counter" ]]
then
# File do not exist
touch "$data_folder$data_file_counter"
echo "0" > "$data_folder$data_file_counter"
runCount="0"
else
runCount=$(cat $data_folder$data_file_counter)
fi
# Last run date
if [[ ! -f "$data_folder$data_file_lastrun" ]]
then
# File do not exist
touch "$data_folder$data_file_lastrun"
echo "0" > "$data_folder$data_file_lastrun"
lastRun=0
else
lastRun=$(cat $data_folder$data_file_lastrun)
fi
If boots passed since last optimize equals with 5 or last optimized more than 5 days before,
then make a full database optimization.
Code:
# Check if its time for optimize
if [ $(( $(date +%s) - $lastRun )) -ge $max_time_dif -o $runCount -ge 5 ]; then
echo "Full mode optimize"
# Save data
echo "0" > "$data_folder$data_file_counter"
echo $(date +%s) > "$data_folder$data_file_lastrun"
# Optimize /data/
optimize_folder "/data/"
echo "All applications' databases were optimized"
Else make a light optimize.
(only phone, contacts, mms and settings)
Code:
else
echo "Light mode optimize"
# Save data
echo $((runCount+1)) > "$data_folder$data_file_counter"
# Only for Galaxy Core
# Count databases optimized
count=0
# phone optimize
optimize_folder "/data/data/com.android.phone/databases/"
# contacts optimize
optimize_folder "/data/data/com.android.providers.contacts/databases/"
# mms optimize
optimize_folder "/data/data/com.android.mms/databases/"
# email optimize
optimize_folder "/data/data/com.android.mms/databases/"
# settings optimize
optimize_folder "/data/data/com.android.settings/databases/"
echo "Important databases were optimized"
fi;
Optimize functions
Code:
# Some functions
# Optimize db
optimize_db(){
# Vacuum and then reindex
$sql_lib $1 'VACUUM;';
$sql_lib $1 'REINDEX;';
#echo $(basename $1)" was optimized."
}
# Optimize every db on folder
optimize_folder(){
local path=$1
count_result=0;
find $path -type f -iname "*.db" -print0 | while IFS= read -r -d $'\0' database; do
optimize_db $database
done
#echo "Databases inside $path were optimized."
}
Use the sqlite binary to VACUUM and REINDEX the given database.
Click to expand...
Click to collapse

[Script][Optimize apks using ZipAlign][v1.0]
Name : Optimize apks using ZipAlign
Version : v1.0
Author : Wes Garner
Suggestions : oknowton
Edited by : DarkThanos
Click to expand...
Click to collapse
This script zipalign applications' apk (only the apks that are not already zipaligned) on every boot.
First boot may take a while.
Before use make a folder "libs" inside "/system/etc/init.d/",
insert the "zipalign" file inside and give it execute permissions (the file is given with the script)
Bugs:(Not for use, more testing needed)
Some apps return an error after zipaligned, and need to be reinstalled.
(Found fix. Zipaligned apk do not holds read rights after copy. Command "cp -p" do not hold permissions. Temp fix "chmod 644". [I need help with that])
A download will be posted when it is stable.
I am not responsible for whatever happens to your phone.
Tested on my Samsung Galaxy Core (I8260)
Need to be tested for stable use.
[Change log]
1.0 Version
Script Public for first time.
Optimize apks using ZipAlign (on every boot check apps).
Click to expand...
Click to collapse
[Dev Doc]
Script code
Code:
#!/system/bin/sh
# Optimize apks using ZipAlign
#
# Work of:
# Wes Garner (Script code)
# oknowton (Suggestions)
#
# Modifications by:
# DarkThanos
#
# For the xda Galaxy Core users
#
# Some variables
# SQLite path
zipalign_lib="/system/etc/init.d/libs/zipalign";
# Data folder path
data_folder="/data/boot_scripts_data/";
# Data database file name
apk_cache="zipalign_apk_cache";
# Counters
count_apps=0
count_zipaligned_apps=0
count_zipalign_failed=0
# Report ZipAlign start
echo "ZipAlign Optimization Start";
# For every apk in /data/app/
for apk in /data/app/*.apk ; do
# Check if this apk is zipaligned
$zipalign_lib -c 4 $apk;
# Get results
not_zipaligned=$?;
# Count app
count_apps=$((count_apps+1))
# If not, align it
if [ $not_zipaligned -eq 1 ]; then
# ZipAlign app
result=`$zipalign_lib -f 4 $apk $data_folder$apk_cache`
if [ -e $data_folder$apk_cache -a ${#result} -eq 0 ]; then
# Successful zipalign
/system/xbin/busybox cp -p $data_folder$apk_cache $apk;
chmod 644 $apk;
rm $data_folder$apk_cache;
count_zipaligned_apps=$((count_zipaligned_apps+1))
else
echo "[ERROR] $result"
# Failed zipalign
count_zipalign_failed=$((count_zipalign_failed+1))
#echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
fi;
done;
# Report results
echo "Apks ZipAligned $count_zipaligned_apps/$count_apps ($count_zipalign_failed failed)";
# Exit
exit 0
I need help with the code:
Code:
/system/xbin/busybox cp -p $data_folder$apk_cache $apk;
chmod 644 $apk;
rm $data_folder$apk_cache;
I try to make all my script work with no busybox. "cp" command do not exist in android (without busybox).
Is "cat" a good alternative?
Also, should I use "chmod 644 $apk;"? "cp -p" do not work and I am pretty sure the script has root rights.
Thanks for your time.
Click to expand...
Click to collapse

I need betatester
Sent from my GT-I8262 using XDA Premium 4 mobile app

NieeLz said:
I need betatester
Click to expand...
Click to collapse
Download the "init.bsu.boot" script (from first post). Create the "/system/etc/init.d/" folder. And run the script (from your download folder) using Script Manager (do not forget to enable "su"). Then check "/data/tmp/init.bsu.log" (open as text) and see the log.
This is an easy safe test.
You can also make a test script, like:
Code:
#!/system/bin/sh
# Test Script
echo "This will be on log."
(You can read the script codes too, I have many comments.)

Related

REQUEST/IDEA for a safety script for tweaking/OC

I had an Idea for a script that would run at bootup, and if a certain variable had a "value" of NOT 1.
then the script would change the CHMOD of a userinit.sh located in the sd-ext from 050 or 777 to 750 then it would change the variable "value" to 0 were it would stay untill another script that runs at shut down or reboot setts the variable to 1 and changes CHMOD back to 050 or 777 so that the userinit.sh is not run.
That way if a change is made during operating the phone that causes the phone to crash with out shutting down properly the script runs which causes the userinit.sh to run and "resets" userinit.sh values to a "default". Otherwise if shut down properly nothing happens.
This could be expanded on to include repairing the EXT or clearing some special cache or other stuff I am unfamiliar with but that you might want to run after a crash.(like logcat?)
any way what do you think? any promise?
I think, for overclocking purposes anyway, making the userinit.sh unrunnable would make the phone break immediately, as I think it would go to the highest available frequency. However, I like the idea, though I'm not sure how to run scripts on shutdown. I think for overclocking, it would check if the shutdown was clean on startup, and if not change the applicable line to the next lowest number, which it would get either from a seperate file or maybe it could be stuffed in the script itself. (Just my somewhat uneducated thoughts)
TheNewGuy said:
I had an Idea for a script that would run at bootup, and if a certain variable had a "value" of NOT 1.
then the script would change the CHMOD of a userinit.sh located in the sd-ext from 050 or 777 to 750 then it would change the variable "value" to 0 were it would stay untill another script that runs at shut down or reboot setts the variable to 1 and changes CHMOD back to 050 or 777 so that the userinit.sh is not run.
That way if a change is made during operating the phone that causes the phone to crash with out shutting down properly the script runs which causes the userinit.sh to run and "resets" userinit.sh values to a "default". Otherwise if shut down properly nothing happens.
This could be expanded on to include repairing the EXT or clearing some special cache or other stuff I am unfamiliar with but that you might want to run after a crash.(like logcat?)
any way what do you think? any promise?
Click to expand...
Click to collapse
Keep it simple. If a change in userinit.sh breaks your system, reboot to recovery and edit it and reboot again.
TheNewGuy said:
I had an Idea for a script that would run at bootup, and if a certain variable had a "value" of NOT 1.
then the script would change the CHMOD of a userinit.sh located in the sd-ext from 050 or 777 to 750 then it would change the variable "value" to 0 were it would stay untill another script that runs at shut down or reboot setts the variable to 1 and changes CHMOD back to 050 or 777 so that the userinit.sh is not run.
That way if a change is made during operating the phone that causes the phone to crash with out shutting down properly the script runs which causes the userinit.sh to run and "resets" userinit.sh values to a "default". Otherwise if shut down properly nothing happens.
This could be expanded on to include repairing the EXT or clearing some special cache or other stuff I am unfamiliar with but that you might want to run after a crash.(like logcat?)
any way what do you think? any promise?
Click to expand...
Click to collapse
most rom devs/tweakers launch userinit.sh by calling it with a sh
e.g.
/system/bin/sh /system/sd/userinit.sh
so it will still run !! ( as init doesn't care about permissions, it is god )
don't believe me?
Code:
echo "echo I ran" > /data/test.sh
chmod 000 /data/test.sh
sh /data/test.sh
Keep it simple. If a change in userinit.sh breaks your system, reboot to recovery and edit it and reboot again.
Click to expand...
Click to collapse
Yea thats the easy way!...
(Seriously I'm not that good at Linux Command Line code,wording,but i'm getting there.)
I think, for overclocking purposes anyway, making the userinit.sh unrunnable would make the phone break immediately, as I think it would go to the highest available frequency. However, I like the idea, though I'm not sure how to run scripts on shutdown. I think for overclocking, it would check if the shutdown was clean on startup, and if not change the applicable line to the next lowest number, which it would get either from a seperate file or maybe it could be stuffed in the script itself. (Just my somewhat uneducated thoughts)
Reply With Quote
Click to expand...
Click to collapse
And I know that most roms now have a script called something like in /system/etc/init.d/20userinit that runs at startup and checks to see if a userinit.sh is present in sd-ext,if so it runs it.Also I noticed that the script can be there but if it is CHMOD to 777 it wont run. This is the "Reset script" Set to restet to something you like and run other tasks to help Fix/Diagnose probs.
The OC changes would be made from a different script such as 86supersettings
Or a userinit located in system/sd maybe ?
The thing is making sure one is read before the other.
Any way I probably will just learn the language better and do it from recovery console.
Thanks again
TheNewGuy said:
Yea thats the easy way!...
(Seriously I'm not that good at Linux Command Line code,wording,but i'm getting there.)
And I know that most roms now have a script called something like in /system/etc/init.d/20userinit that runs at startup and checks to see if a userinit.sh is present in sd-ext,if so it runs it.Also I noticed that the script can be there but if it is CHMOD to 777 it wont run. This is the "Reset script" Set to restet to something you like and run other tasks to help Fix/Diagnose probs.
The OC changes would be made from a different script such as 86supersettings
Or a userinit located in system/sd maybe ?
The thing is making sure one is read before the other.
Any way I probably will just learn the language better and do it from recovery console.
Thanks again
Click to expand...
Click to collapse
chmod 777 makes it rw and executable by everyone!!!!!!!!
have a look here
http://www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html
but as I mentioned above, init ( the initial progam runs as root and doesn't care about permissions, ( it wouldn't be very good at doing initialising the system if it had to seek permission )
Yea your right. Well I said I wasn't that good at this linux stuff! Now I Proved it.
Any way as you can see this is more of a request..... I still think it's a good Idea.
Thanks for your help FireRat.
Keep it simple. If a change in userinit.sh breaks your system, reboot to recovery and edit it and reboot again.
Click to expand...
Click to collapse
I understand how I could manualy Replace the modified script with a default one that was on my sdcard from within recovery after a faild OC change...but..
Are you saying I could actualy modify the original script from recover? Do you have any info on how? A link?
TheNewGuy said:
I understand how I could manualy Replace the modified script with a default one that was on my sdcard from within recovery after a faild OC change...but..
Are you saying I could actualy modify the original script from recover? Do you have any info on how? A link?
Click to expand...
Click to collapse
If you have RA-Recovery, adb works, so you can pull/push the userinit.sh script. You can also enter the terminal and use vi to edit it from recovery. You may have to mount the ext partition first, but that's pretty easy. "mount /system/sd" will do it, if /system/sd doesn't exist, "mkdir /system/sd".
Ok, Thanks that makes sense. I'm still learning adb though. And I tried vi once before with no luck. But now I know what to learn about.
Thanks a lot I appreciate it.
TheNewGuy said:
Ok, Thanks that makes sense. I'm still learning adb though. And I tried vi once before with no luck. But now I know what to learn about.
Thanks a lot I appreciate it.
Click to expand...
Click to collapse
ok, this would do what you want
/system/bin/shutdown
bold is new
Code:
#!/system/bin/sh
stop;
stop dhcpcd;
sleep 1;
[B]echo "1" > /data/cleanshutdown[/B]
for i in `cat /proc/mounts | cut -f 2 -d " "`;
do
busybox mount -o remount,ro $i 2>&1 > /dev/null;
done
sync;
if [ "$1" = "-r" ];
then
toolbox reboot -f;
else
toolbox reboot -fp;
fi
your script
Code:
#!/system/bin/sh
if [ "`cat /data/cleanshutdown`" != "1" ];
then
echo "shutdown was not clean"
[B]your tweaks[/B]
else
echo "shutdown was clean"
[B]your tweaks[/B]
fi
echo "0" > /data/cleanshutdown
I'm not sure you need it,
this is for education value, if you want to play ^^^ is where to start
Thank You!
That is perfect
I need to add all of this to the startup script right?
if [ "`cat /data/cleanshutdown`" != "1" ];
then
echo "shutdown was not clean"
your tweaks
else
echo "shutdown was clean"
your tweaks
fi
echo "0" > /data/cleanshutdown
Click to expand...
Click to collapse
I am going to use the beta boot up script from ZKX called 86Supersettings, but I could use a userinit/user.conf like most do. Correct?
TheNewGuy said:
Thank You!
That is perfect
I need to add all of this to the startup script right?
I am going to use the beta boot up script from ZKX called 86Supersettings, but I could use a userinit/user.conf like most do. Correct?
Click to expand...
Click to collapse
well, a .conf file should be just that
a file with configurations , not an executable script
well, a .conf file should be just that
a file with configurations , not an executable script
Click to expand...
Click to collapse
OK. I guess I meant both together. I would use the user.conf to make tweaks. Then have to modify the userinit.sh with the part you made. Something like.
#!/system/bin/sh--LEAVE THIS OUT. ITS ALL READY AT THE BEGINNING
if [ "`cat /data/cleanshutdown`" != "1" ];
then
echo "shutdown was not clean"
Dont run user.conf
and set cpu or other stuff to "default"
else
echo "shutdown was clean"
Run user.conf for tweaked settings
fi
echo "0" > /data/cleanshutdown
Click to expand...
Click to collapse
If I'm way off then I guess I need to re-read the Userinit thread.
TheNewGuy said:
OK. I guess I meant both together. I would use the user.conf to make tweaks. Then have to modify the userinit.sh with the part you made. Something like.
If I'm way off then I guess I need to re-read the Userinit thread.
Click to expand...
Click to collapse
well, in practise it doesn't matter
the file extension is only for use humans, if I'm looking in a directory and I see .conf I expect it to be a configuration file, I see .sh, its a shell script, .py python, pl perl .......
I see. Well Thanks again for your help. Your script does work. I tried it. crash on purpose.
I still have a lot to learn.
Folks;
1) If you're OC'ing via SetCPU, remember that this doesn't change the recovery kernel, and you can uninstall SetCPU from Recovery. From there, all you need is a "safe" userinit.sh.
3) If you're OC'ing via userinit.sh -- same deal. Your phone crashes on you and you just edit it to a safe config from recovery.
Tweak away.
This is what I ended up with
Thanks to
XxKolohexX
FireRat
Licknuts
Code:
#!/system/bin/sh
#
echo 255 >/sys/class/leds/blue/brightness;
echo "+++ Now entering the speedy madness of Z.X.D.!"
echo "----- let's clear that Cache first."
echo "----- Too much DBs make System go sloow..."
echo "----- Also be shure to check out CacheMate"
echo "----- It's in the Market. (Made by Android AppCritic)."
echo "----- It's way more powerfull than this script!"
echo "----- (Times 10 or 100... Clears everything :P)"
echo "----- And this script already took hours to build..."
echo "----- domenukk - 2010."
find /data/data -name app_admob_cache | while read line; do du -s $line/* | cut -f1; rm -Rf $line/*; done;
find /data/data -name cache | while read line; do du -s $line/* | cut -f1; rm -Rf $line/*; done;
find /data/data -name google_analytics.db | while read line; do du -s $line | cut -f1; rm -Rf $line; done;
find /data/data -name webviewCache.db | while read line; do du -s $line | cut -f1; rm -Rf $line; done;
rm -rf /data/data/com.facebook.katana/files
rm -rf /data/data/com.google.android.apps.genie.geniewidget/app_news_image_cache
rm -rf /data/data/com.code.i.music/app_admob_cache
rm -rf /data/data/fm.last.android/databases/google_analytics.db
echo "--- All the Cache has been cleared."
sleep 10
echo 0 >/sys/class/leds/blue/brightness;
####determin if shutdown was clean####
if [ "`cat /data/cleanshutdown`" != "1" ];
then
####RUN CLEAN SHUTDOWN SCRIPT####
echo 255 >/sys/class/leds/green/brightness;
####Turbo Script by [email protected]####
####Prioritize everyting ####
echo "----- Enabling Turbo."
dirty_writeback_centisecs=500
/system/bin/prior &
#
# Linux-SWAP
#
if [ -e /dev/block/mmcblk0p3 ];
then
if [ -n /dev/block/mmcblk0p3 ];
then
echo "+++ Set Linux Swap"
busybox mkswap /dev/block/mmcblk0p3;
fi;
if [ -e /dev/block/mmcblk0p3 ];
then
echo "+++ Set Swapiness"
echo 100 > /proc/sys/vm/swappiness;
echo "+++ Activate Swap"
busybox swapon /dev/block/mmcblk0p3;
fi;
fi;
####Better CPU Settings...####
echo "----- Speed up the CPU"
echo 633600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo 122800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo 95 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold;
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load;
echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias;
echo 0 >/sys/class/leds/green/brightness;
echo 255 >/sys/class/leds/blue/brightness;
else
####RUN DIRTY SHUTDOWN SCRIPT####
echo 255 >/sys/class/leds/red/brightness;
####Turbo Script by [email protected]####
####Prioritize everyting ####
echo "----- Enabling Turbo."
dirty_writeback_centisecs=500
/system/bin/prior &
#
# Linux-SWAP
#
if [ -e /dev/block/mmcblk0p3 ];
then
if [ -n /dev/block/mmcblk0p3 ];
then
echo "+++ Set Linux Swap"
busybox mkswap /dev/block/mmcblk0p3;
fi;
if [ -e /dev/block/mmcblk0p3 ];
then
echo "+++ Set Swapiness"
echo 83 > /proc/sys/vm/swappiness;
echo "+++ Activate Swap"
busybox swapon /dev/block/mmcblk0p3;
fi;
fi;
####Better CPU Settings...####
echo "----- Speed up the CPU"
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo 122800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo 45 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold;
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load;
echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
echo 200 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias;
fi;
echo "0" > /data/cleanshutdown
echo "+++ continue on lame stock SuperD boot "
##Clearing Davlik-Cache##
for dc in dalvik-cache;
do
umount /cache/$dc;
rm -fr /cache/$dc;
mkdir /cache/$dc;
chown 1000:1000 /cache/$dc;
chmod 771 /cache/$dc;
mount -o bind /data/$dc /cache/$dc;
done;
Named 86supersettings so it runs after userinit.sh if one exists.
I put some Led indicators in so you can tell if it ran right at boot up. (about all I did besides copy and paste) Thinking about adding some other stuff like repair ext, or some kind of log to help me see what happed... any suggestions.
OK, here's another Idea for another safety feature...
I would like to "hard code" a temp fail-safe in to the code. I would like to get rid of SetCPU and when OC-ing it's nice to have a temp failsafe.SHUTDOWN!LOL
Any way I guess I would just add a few lines to some existing script in my phone?.... Any suggestions.
Thanks for your time.

[KERNEL MOD] keytimer user setting script for mkasick Epic 4G keyboard patch

After having shared this on the #epic channel, I decided to share it here... This is for kernel devs who've incorporated mkasick's sysfs keyboard patch, located here.
This kernel mod and accompanying script are meant to be used in conjunction with mkasick's epic keyboard patch, and will perform the following:
1) Allow the kernel developer to easily choose the initial timer_delay value for the patch
2) Allow the end user to adjust the setting, and have it persist past boot
3) Checks user input for the setting, and not allow settings to occur that will make the keyboard unresponsive, or unusable
Files:
keytimer_initscript.sh
keytimer
Instructions for kernel devs:
1) Take the script inside keytimer_initscript.sh, and add it to your custom initscript called from init.rc
Note: place after the init.d section, or theimpaler747 script will overwrite the keytimer script.
2) Place the keytimer script inside your initramfs /sbin
Instructions for users:
1) Have a kernel with this mod inside, like mine:
DRockstar.Clean.Kernel.EC05.v1.02.zip
Note: Other kernel devs have this now, so it should come to your favorite kernel soon!
Also: If your current kernel has the mkasick sysfs keyboard patch, but not my kernel mod, you can take the keytimer script, and place it /system/xbin, and chmod 755 /system/xbin/keytimer. Without my kernel mod, the setting won't persist through a reboot, but it will give you an easy way to change the setting.
2) Open Connectbot or Android Terminal, and type su
3) type command: keytimer
it will show usage and the current value, the default is 7.
example use to change to theimpaler747 value of 5:
keytimer 5
Accepted values are 1 through 16.
The change will be immediate, and will persist after reboot.
Hope you all like this one, enjoy it!
CODE:
keytimer_initscript.sh :
Code:
#!/system/bin/sh
# keytimer script to be called by init.rc, written by DRockstar for the Epic 4G
# assumes busybox is already installed
# kernel developers may just copy script to existing custom init script
# can be adjusted by accompanied keytimer script in /sbin
# keyboard patch sysfs call 7 for snappy keyboard performance
if [ ! -f "/data/local/timer_delay" ]; then
echo 7 > /data/local/timer_delay
fi
cat /data/local/timer_delay > /sys/devices/platform/s3c-keypad/timer_delay
keytimer :
Code:
#!/system/bin/sh
# keytimer shortcut script by DRockstar
usage()
{
echo "keytimer: shortcut for Epic 4G keyboard response time"
echo "usage: keytimer , 7 is default, 1 - 16 accepted"
}
error()
{
usage
echo "error: $1"
exit
}
mount -t rootfs -o remount,rw / /
if [ "$1" = "" ]; then
timer="`cat /sys/devices/platform/s3c-keypad/timer_delay`"
usage
echo "current keytimer value is $timer"
exit
fi
case $1 in *[!0-9]*)
error "input is not a positive number"
esac
if [ $1 -gt 16 ]; then
error "only numbers 1 - 16 are accepted"
fi
echo $1 > /sys/devices/platform/s3c-keypad/timer_delay
echo $1 > /data/local/timer_delay
mount -t rootfs -o remount,ro / /
yeeeah
Good job DRockstar ....This is saweet
good **** DRockstar....i already have it commited to my source for the next version
keep up the good work!
OK, links fixed, with code also posted.
Posted instructions for those who just want to use keytimer script, in case your favorite kernel doesn't have the keytimer mod installed yet, but has the keyboard patch installed.
Thanks to Rodderik for server space, after fossnet server got toasted.
Peace!
I'm pleased that folks are making good use of the sysfs patch, and making the user-side keytimer configuration much more approachable and useful. Thanks for doing this, it means a lot.
DRockstar said:
After having shared this on the #epic channel, I decided to share it here... This is for kernel devs who've incorporated mkasick's sysfs keyboard patch, located here.
This kernel mod and accompanying script are meant to be used in conjunction with mkasick's epic keyboard patch, and will perform the following:
1) Allow the kernel developer to easily choose the initial timer_delay value for the patch
2) Allow the end user to adjust the setting, and have it persist past boot
3) Checks user input for the setting, and not allow settings to occur that will make the keyboard unresponsive, or unusable
Files:
keytimer_initscript.sh
keytimer
Instructions for kernel devs:
1) Take the script inside keytimer_initscript.sh, and add it to your custom initscript called from init.rc
Note: place after the init.d section, or theimpaler747 script will overwrite the keytimer script.
2) Place the keytimer script inside your initramfs /sbin
Instructions for users:
1) Have a kernel with this mod inside, like mine:
DRockstar.Clean.Kernel.EC05.v1.01.zip
Note: Other kernel devs have this now, so it should come to your favorite kernel soon!
Also: If your current kernel has the mkasick sysfs keyboard patch, but not my kernel mod, you can take the keytimer script, and place it /system/xbin, and chmod 755 /system/xbin/keytimer. Without my kernel mod, the setting won't persist through a reboot, but it will give you an easy way to change the setting.
2) Open Connectbot or Android Terminal, and type su <enter>
3) type command: keytimer
it will show usage and the current value, the default is 7.
example use to change to theimpaler747 value of 5:
keytimer 5
Accepted values are 1 through 16.
The change will be immediate, and will persist after reboot.
Hope you all like this one, enjoy it!
CODE:
keytimer_initscript.sh :
Code:
#!/system/bin/sh
# keytimer script to be called by init.rc, written by DRockstar for the Epic 4G
# assumes busybox is already installed
# kernel developers may just copy script to existing custom init script
# can be adjusted by accompanied keytimer script in /sbin
# keyboard patch sysfs call 7 for snappy keyboard performance
if [ ! -f "/data/local/timer_delay" ]; then
echo 7 > /data/local/timer_delay
fi
cat /data/local/timer_delay > /sys/devices/platform/s3c-keypad/timer_delay
keytimer :
Code:
#!/system/bin/sh
# keytimer shortcut script by DRockstar
usage()
{
echo "keytimer: shortcut for Epic 4G keyboard response time"
echo "usage: keytimer <number>, 7 is default, 1 - 16 accepted"
}
error()
{
usage
echo "error: $1"
exit
}
mount -t rootfs -o remount,rw / /
if [ "$1" = "" ]; then
timer="`cat /sys/devices/platform/s3c-keypad/timer_delay`"
usage
echo "current keytimer value is $timer"
exit
fi
case $1 in *[!0-9]*)
error "input is not a positive number"
esac
if [ $1 -gt 16 ]; then
error "only numbers 1 - 16 are accepted"
fi
echo $1 > /sys/devices/platform/s3c-keypad/timer_delay
echo $1 > /data/local/timer_delay
mount -t rootfs -o remount,ro / /
Click to expand...
Click to collapse
Sorry for asking this noob question but I just want to clarify. This is the stock Kernel with mkasicks fix to allow for the keyboard tweaks correct?
Nothing else is different about the kernel? If so, this is exactly what I was looking for.
Updated the kernel download to v1.02... which fixed some apps like metamorph not working with the location I set for busybox.
I need to make a post for the kernel now... sources are now posted at github.com/DRockstar.
to answer the previous question, yes, this kernel is intended to be a simple rooted kernel, based off samsung stock, with only simple mods ... its feature are:
* Root and busybox with minimal system mods
* designed to allow OTA update after flashing back the stock kernel
* mkasick sysfs keyboard patch, with my keytimer script
* voodoo sound 7 by supercurio, controlled by voodoo control app in android market
* additonal custom scripts in /sbin for cleaning root, busybox, and flash kernels and recoveries
This kernel was built to replace the traditional one click root method for my all in one root and recovery script.
Sent from my SPH-D700 using Tapatalk

[DEV][SCRIPT] Enhanced init.d support

Okay, I worked a bit on something to add a little more options to init.d scripts for my ROM's. I came up with the below solution and thought I should share it with whomever would like a bit more options in their own ROM's. This is a first draft so some of things can properly be done in other ways, but it works and it does add a lot more options when building startup scripts while it is compatible with regular init.d scripts as well. But fell free to pitch in with ideas if you like.
Note that this thread is directed to ROM cookers, but can be used by anyone that knows how to edit ramdisk's.
So there are several problems with the regular init.d methods. First of all there are two different ways of executing the scripts and it differs from ROM to ROM which method has been implemented. We have the "exec /system/bin/sysinit" which will execute all of the scripts before continuing with the normal boot and we have the service sysinit which will execute all scripts while the normal boot is running. Both are useful for different things but no ROM has both.
Also init.d will just start executing the scripts before/during the normal boot, depended on the method, but what if we need it to execute something at a specific time during boot. Before folder structures and such are created in /data? Or when the phone has completely booted into the GUI. Or before the phone is turned off and so on.
This method will implement different states where different parts of a script can be executed depended on where in the boot process we are. All it requires is a more extended sysinit file and a couple of extra lines in the init.rc file.
File: /init.rc
Code:
on early-init
##
# Whatever goes here
##
on init
##
# Whatever goes here
##
on fs
##
# Mount /system
##
# Make sure that we have the synlinks we need to use sysinit
symlink /system/bin/sysinit /system/bin/sysinit.onstart
symlink /system/bin/sysinit /system/bin/sysinit.onfs
symlink /system/bin/sysinit /system/bin/sysinit.onpostfs
symlink /system/bin/sysinit /system/bin/sysinit.onpostfsdata
symlink /system/bin/sysinit /system/bin/sysinit.onboot
symlink /system/bin/sysinit /system/bin/sysinit.onsysinit
symlink /system/bin/sysinit /system/bin/sysinit.onfinalize
symlink /system/bin/sysinit /system/bin/sysinit.oncomplete
symlink /system/bin/sysinit /system/bin/sysinit.onshutdown
exec /system/bin/sysinit.onstart
##
# Mount the rest of the partitions and remount /system without write permissions
##
exec /system/bin/sysinit.onfs
on post-fs
##
# Whatever goes here
##
exec /system/bin/sysinit.onpostfs
on post-fs-data
##
# Whatever goes here
##
exec /system/bin/sysinit.onpostfsdata
##
# If you want to include an additional *.rc file, do it here at the end of post-fs-data
##
on boot
##
# Whatever goes here
##
exec /system/bin/sysinit.onboot
start sysinit
##
# Start any other services
##
on property:init.svc.bootanim=stopped
start syscomplete
on property:sys.boot_completed=1
exec /system/bin/sysinit.onfinalize
on property:sys.shutdown.requested=1
exec /system/bin/sysinit.onshutdown
service sysinit /system/bin/sysinit.onsysinit
disabled
oneshot
service syscomplete /system/bin/sysinit.oncomplete
disabled
oneshot
##
# The rest of the file
##
File: /system/bin/sysinit
Code:
#!/system/bin/sh
export PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
if [ -d /system/etc/init.d ]; then
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
while :
do
if [ ! -f /sysinit.stage.prop ]; then
mount -o remount,rw /
touch /sysinit.stages.prop
mount -o remount,ro /
fi
if ( [ "$INIT_STATE" != "onfinalize" ] && [ "$INIT_STATE" != "oncomplete" ] ) || ( [ "$INIT_STATE" = "onfinalize" ] && [ ! -z "`grep onpostsysinit /sysinit.stages.prop`" ] ) || ( [ "$INIT_STATE" = "oncomplete" ] && [ ! -z "`grep onfinalize /sysinit.stages.prop`" ] ); then
if [ "$INIT_STATE" = "onsysinit" ]; then
RUN_STATES="onsysinit onpostsysinit"; sleep 1
elif [ "$INIT_STATE" = "oncomplete" ]; then
RUN_STATES="onservice oncomplete"
else
RUN_STATES="$INIT_STATE"
fi
for x in $RUN_STATES; do
log -p v -t sysinit "Switching to state '$x'..."
case $x in
# Make it compatible with old init scripts
onboot|"") FILES="`find /system/etc/init.d -type f | sort`" ;;
*) FILES="`find /system/etc/init.d -type f -iname '*.rc' | sort`" ;;
esac
for i in $FILES; do
if [ ! -d $i ] && [ -x $i ]; then
log -p v -t sysinit "Executing $i..."
if [ "$x" = "onservice" ]; then
logwrapper $i $x > /dev/null &
else
logwrapper $i $x
fi
else
log -p w -t sysinit "Skipping $i. Not an executable!"
fi
done
mount -o remount,rw /
echo $x >> /sysinit.stages.prop
mount -o remount,ro /
done
break
fi
sleep 1
done
fi
To use this you need to end the names of your init script with .rc like "55<name>.rc" instead of just "55<name>". This is to keep it compatible with regular init.d scripts.
This will allow you to build init.d scripts like this
Code:
#!/system/bin/sh
case $1 in
onstart)
# Do something right after the system partition has been mounted RW (No other partitions at this time)
;;
onfs)
# Do something right after the rest of partitions has been mounted and system has been remounted RO, before any of them are used or changed in any way.
;;
onpostfs)
# This is almost the same as onfs, only minor changes has normally been made here
;;
onpostfsdata)
# Do something after the /data partition has been rebuild with folders, permission, ownership and so on
;;
onboot)
# Do something right before Android starts booting and it's services are triggered
;;
onsysinit)
# Do something while Android is booting. This will NOT stall the boot process but run along side it
;;
onpostsysinit)
# Do something as soon as onsysinit has finished
;;
onfinalize)
# Do something when the system is almost booted, this also includes the sysinit parts above
;;
onservice)
# Do some constant work in the background (Service/Daemon)
;;
oncomplete)
# Do something when the phone is fully booted and the boot animation is gone
;;
onshutdown)
# Do something before the phone is turned off or rebooted
;;
esac
EDIT 1
Added 'onfinalize' which is actually the old oncomplete. The new oncomplete runs as a service like onsysinit and onpostsysinit to ensure that you are able to use things like "sleep" without stalling the system.
Rewrote sysinit, much cleaner now
EDIT 2
Added 'onservice' which can be used to run a constant task in the background after the phone has booted
Great concept and great work
I can see how this would be very handy!
Sent from my PG86100 using Tapatalk 2
looks intresting..Hmmmmm
Genius man. Awesome stuff.
Sent from my SCH-I500 using Tapatalk 2
Awesome great work. The last line say do comething before the phone is turned off or rebooted. is it suppose to say something.
Sent from my HTC Desire CDMA using Tapatalk 2
jayallen1980 said:
Awesome great work. The last line say do comething before the phone is turned off or rebooted. is it suppose to say something.
Sent from my HTC Desire CDMA using Tapatalk 2
Click to expand...
Click to collapse
'something' is correct, have been changed
Some examples would be good
Can you please? (Example of Executing Juwe's RAM script will be nice in all cases)
What if I want to keep init.d folder empty and integrate my scripts inside boot.img? and then execute them inside it?
varun.chitre15 said:
Some examples would be good
Can you please? (Example of Executing Juwe's RAM script will be nice in all cases)
What if I want to keep init.d folder empty and integrate my scripts inside boot.img? and then execute them inside it?
Click to expand...
Click to collapse
Why would you integrate scripts into the boot.img? The point of init.d is to be able to add things to boot without changing the boot.img. If you want to execute things from within the boot.img, then just place your scripts in it (sbin would be a good place) and execute it the same way my example executes /system/bin/sysinit.
And as for examples, it's easy. Just place your code in that section (onboot, onfs etc) where you want the code to be executed. The onboot is the default in process in most ROM's and also where regular init.d scripts is executed in this example.
dk_zero-cool said:
Why would you integrate scripts into the boot.img? The point of init.d is to be able to add things to boot without changing the boot.img. If you want to execute things from within the boot.img, then just place your scripts in it (sbin would be a good place) and execute it the same way my example executes /system/bin/sysinit.
And as for examples, it's easy. Just place your code in that section (onboot, onfs etc) where you want the code to be executed. The onboot is the default in process in most ROM's and also where regular init.d scripts is executed in this example.
Click to expand...
Click to collapse
because the point of this is to start scripts when you want.. there is a few scripts I have that can't be ran until os is loaded, there for making this a great setup for me.
init.d & boot.img runs everything at boot... not after boot.
eugene373 said:
because the point of this is to start scripts when you want.. there is a few scripts I have that can't be ran until os is loaded, there for making this a great setup for me.
init.d & boot.img runs everything at boot... not after boot.
Click to expand...
Click to collapse
The 'oncomplete' runs everything when the system is fully loaded, that's the point of this init.d system, to be able to run scripts in different ways during different stages.
dk_zero-cool said:
The 'oncomplete' runs everything when the system is fully loaded, that's the point of this init.d system, to be able to run scripts in different ways during different stages.
Click to expand...
Click to collapse
yeah I got it..... I've been having one hell of a time starting script until I cam across this...
If it starts like a normal init.d file it hangs the boot process... with this edit I can trigger it to run on bootcomplete with out hanging the service
sorry, I just noticed I quoted you and not the other guy
eugene373 said:
yeah I got it..... I've been having one hell of a time starting script until I cam across this...
If it starts like a normal init.d file it hangs the boot process... with this edit I can trigger it to run on bootcomplete with out hanging the service
sorry, I just noticed I quoted you and not the other guy
Click to expand...
Click to collapse
Yes oncomplete, oninit and onservice will not stall the process, oninit will however stall onfinalize, oncomplete and onservice. onservice will run the script in a seperate process in the background, so that will not even stall the rest of the init.d scripts while executing, making that great for scripts that should keep running, or where you don't know how long they should run.
dk_zero-cool said:
Yes oncomplete, oninit and onservice will not stall the process, oninit will however stall onfinalize, oncomplete and onservice. onservice will run the script in a seperate process in the background, so that will not even stall the rest of the init.d scripts while executing, making that great for scripts that should keep running, or where you don't know how long they should run.
Click to expand...
Click to collapse
Adding this into all my boot.img from now on & I'll be sure to link this thread...
I think this should be the new standard for all Devs, this method is not only a great idea!
But for the End User, there's so much more control over what can / should be done on starting process...
I personally want to thank you for this, as this truely is one of the better methods I've ever seen!!
~Eugene
dk_zero-cool, I'd like to ask you, why you use soft-links and not parameters?
It will remove all
Code:
symlink /system/bin/sysinit /system/bin/sysinit.*
from init.rc and you will not need to use case in sysinit.
Because this whole construction:
Code:
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
seems to me like overload.
hashnon said:
dk_zero-cool, I'd like to ask you, why you use soft-links and not parameters?
It will remove all
Code:
symlink /system/bin/sysinit /system/bin/sysinit.*
from init.rc and you will not need to use case in sysinit.
Because this whole construction:
Code:
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
seems to me like overload.
Click to expand...
Click to collapse
Because I have had bad experience using arguments along with the exec command, so I try to avoid that. Mostly because I can't remember the issues anymore.
As for overload, this is to small to be noticed, specially when this is only executed a couple of times during startup. If this was to be executed every couple of minute during the phone on state, then sure. But when the phone has booted, sysinit is no longer used.
Pretty neat design. I've found that having to deal with some of the escaping of an exec can be a nightmare too.
In the kernel ramdisk of my Xperia ray, there are two kinds of inits, init.rc and init.semc.rc.
The "on fs" exists in init.semc.rc (where i can see the commands to mount the partitions). In init.rc there's no "on fs" between "on early-fs" and "on post-fs".
So i've put the "on fs"-part in init.semc.rc and the rest of your fabulous work into init.rc. When i look after booting into the /system/bin/ directory i can see all the "sysinit.on........." symlinks. Is that proof that i did everything right so far? Haven't tried any script yet to be honest.
Kaskade said:
In the kernel ramdisk of my Xperia ray, there are two kinds of inits, init.rc and init.semc.rc.
The "on fs" exists in init.semc.rc (where i can see the commands to mount the partitions). In init.rc there's no "on fs" between "on early-fs" and "on post-fs".
So i've put the "on fs"-part in init.semc.rc and the rest of your fabulous work into init.rc. When i look after booting into the /system/bin/ directory i can see all the "sysinit.on........." symlinks. Is that proof that i did everything right so far? Haven't tried any script yet to be honest.
Click to expand...
Click to collapse
Yes some phones have extra init files for onfs. Mostly if they use different file system types. What you did is correct in this case.
You can check the file /sysinit.stages.prop to see if all stages was executed. If one stage is missing from that file, it was not executed.
Deleted.
hi is ths still working in android marshmallow? cant find sysinit file in system/bin/sysinit

[Q] Root with encrypted device

Is it possible to have the following all at the same time?
- SE Linux permissive Kernel (I use linux on android, so this is a must to mount a loopback filesystem and chroot)
- Encrypted Device
- Encrypted SD Card
- Root Access
Every time I try to do it I lose one of them, its like a game of choose any three of the four.
If I flash the RDDT (nd2) Rom I can get everything except for the SD card encrypted.
If I install the MOAR rom I get everything except for ROOT (I lose root after encrypting the device). Once the device is encrypted I can't flash from TWRP because it can't decrypt either. I would just Towel Root with the MOAR Rom, but it says that the device is not supported.
I even played around with MOAR 2.0 and flashed a different kernel, (the governaa). I think I got all four, but my data/voice modem wouldn't work.
I have played around with the idea of just using an ND2 based rom and just mounting my sd card manually with LUKS, but it'd be awesome if someone has figured this out.
Other approaches that don't work.
If I try cyanogenmod I can get everything except for sd card encryption.
cryptsetup script
I was able to get cryptsetup working so now I can access my external sd card. Here's how it works:
I installed a cyanogenmod 11 rom on my phone, though any se linux permissive rom should do.
I just used "Luks Manager" from the play store in order to get access to a cryptsetup binary.
I wrote a few shell scripts:
crypt_down
Code:
#!/usr/bin/env sh
source ./crypt_env
MOUNTED=`mount | grep $UBLOCK_PATH|wc -l`
if [ $MOUNTED -eq 0 ]; then
exit
fi
umount $MNT_PATH
lm.cryptsetup luksClose $UBLOCK_PATH $MNT_PATH
crypt_up
Code:
#!/system/xbin/env bash
source ./crypt_env
# open block device - unencrypted
lm.cryptsetup luksOpen $BLOCK_PATH $UBLOCK_ID
if [ ! -d "$MNT_PATH" ]; then
echo Creating $MNT_PATH
mkdir $MNT_PATH
fi
HAS_PART=`blkid | grep $UBLOCK_PATH | wc -l`
if [ $HAS_PART -eq 0 ]; then
# format unencrypted as ext4
mke2fs -F -t ext4 $UBLOCK_PATH
else
echo 'Already partitioned, proceeding...'
fi
# mount
echo Mounting $UBLOCK_PATH AT $MNT_PATH
mount -t ext4 -o rw $UBLOCK_PATH $MNT_PATH
crypt_env
Code:
#!/usr/bin/env bash
CRYPTBIN=lm.cryptsetup
BLOCK_ID=mmcblk1p1
UBLOCK_ID=luks_external_sd
BLOCK_PATH=/dev/block/$BLOCK_ID
UBLOCK_PATH=/dev/mapper/$UBLOCK_ID
MNT_PATH=/external_sd
crypt_install
Code:
#!/system/xbin/bash
source ./crypt_env
# get size of block device in byted
BYTECOUNT=`blockdev --getsize64 $BLOCK_PATH`
KBCOUNT=$((BYTECOUNT / 10**3))
MBCOUNT=$((BYTECOUNT / 10**6))
GBCOUNT=$((BYTECOUNT / 10**9))
# bail if bin missing
if [ ! -f `which $CRYPTBIN` ]; then
echo $CRYPTBIN not found!
exit
fi
echo
echo WARNING: THIS COMMAND WILL WIPE ALL DATA ON BLOCK
echo DEVICE $BLOCK_PATH
echo This device has...
echo Bytes: $BYTECOUNT
echo KiloBytes: $KBCOUNT
echo MegaBytes: $MBCOUNT
echo GigaBytes: $GBCOUNT
echo
echo The size listed above SHOULD be the same size
echo as your external sd card. IF IT IS NOT YOU SHOULD
echo NOT CONTINUE, IT COULD BRICK YOUR DEVICE.
echo
echo 'Edit "crypt_env" to change targeted block device'
echo
read -r -p "Type 'YES' in all caps to continue... " response
if [[ $response != "YES" ]]; then
echo 'You did not say "YES"'
exit
fi
echo
echo "WARNING: Randomization can take a LONG time"
echo ' Estimated (/dev/urandom) fast speed: 1.989MB/s'
echo ' Estimated time:' $((MBCOUNT / 114)) min
echo
echo ' Estimated (/dev/random) slow speed: 0.545MB/s'
echo ' Estimated time:' $((MBCOUNT / 32)) min
echo
echo
echo 'Would you like to randomize the device? (y/n) '
read response
if [[ $response == "y" ]]; then
read -r -p 'Use slow randomization method? (y/n) ' response
if [[ $response == 'y' ]]; then
RANDOMIZER=/dev/random
DDBS=512KB
else
# experimentally determined that bs=1024KB is fastest
# for my device
# oddly enough bs=1M is SUPER slow
RANDOMIZER=/dev/urandom
DDBS=1024KB
fi
dd if=$RANDOMIZER of=$BLOCK_PATH bs=$DDBS
echo Randomization complete!
fi
echo Luks formatting $BLOCK_PATH
# format block device
$CRYPTBIN luksFormat $BLOCK_PATH
echo "\nCrypt Install complete. Run crypt_up to access device \n"
Run
bash ./crypt_install
bash ./crypt_up
Additional notes
Another thing to mention is that for the above scripts to work you must unmount your sd card FIRST.
Does anyone familiar with android know how I could shim this into the 'mount sd card' option in the settings > storage dialog?
It wouldn't be difficult to modify this to run as an init.rc, but better integration with the settings menu would be perfect.
I'm on my phone right now, but maybe a grep of a rom would point me in the right direction.
Any help much appreciated!
hattwj said:
Another thing to mention is that for the above scripts to work you must unmount your sd card FIRST.
Does anyone familiar with android know how I could shim this into the 'mount sd card' option in the settings > storage dialog?
It wouldn't be difficult to modify this to run as an init.rc, but better integration with the settings menu would be perfect.
I'm on my phone right now, but maybe a grep of a rom would point me in the right direction.
Any help much appreciated!
Click to expand...
Click to collapse
If you're using Cyanogen you should be able to use Udev but I'm not sure how it's implemented or really if it still is implemented in Cyanogenmod.
Check this out http://www.reactivated.net/writing_udev_rules.html#external-run
You'd want to use the add Action variable if possible. Either that or just add what you need to load at startup via init.rc which would probably be easier depending on what is going on when you run whatever it is you need to mount the encrypted sd card. I didn't read through your scripts.

[GUIDE][TUT] Learn basic scripting, how to execute scripts, mod building

Hello guys, I want to share my expirience with users who wants to learn basic scripting stuff, busybox commands, how to use them, how to execute them, how to make .sh files.
Ok, let's start!!! ​
First we must to learn what is busybox. BusyBox is software that provides several stripped-down Unix tools in a single executable file. It runs in a variety of POSIX environments such as Linux, Android.
Busybox allows you or programs to perform actions on your phone using Linux (copied from Unix) commands. Android is basically a specialized Linux OS with a Java compatible (Dalvik) machine for running programs. The Android kernel is a modified version of the Linux kernel (that is why the Android kernel must always be open source). Busybox gives functionality to your phone that it does not have without it. Many programs, especially root programs such as Titanium Backup, require busybox to perform the functions of the program. Without busybox installed your phone is much more limited in what it can do.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Here is some info about busybox, you can track here release dates, you can download sources...
http://spblinux.de/2.0/doc/commands.html
Also here is busybox installer for our "linux devices" heheh ^~^ by stericson. You have two versions of it as you see paid and free.
Chose paid if you want to donate him for awesome job.
Free:
https://play.google.com/store/apps/details?id=stericson.busybox
Paid(PRO):
https://play.google.com/store/apps/details?id=stericson.busybox.donate
After that you need Terminal app, you can download it from playstore too.
Link: Download it from here
This app emulates Linux terminal, with it you can access to android shell.
Lets's start with learning basic terminal stuff
The most of shell commands doesn't need root access, but some of them are need it.
To give root access to the terminal app, you need to type next.
Code:
su [I](press enter)[/I]
After pressing enter, another window will popup to grant root access. Tap on GRANT
***When you typing something into the terminal window, take care because EVERYTHING IS CASE SENSITIVE.***
We all know there are three permissions per group on a file read,write,execute or rwx.
To set permissions as rw-r--r-- we use chmod 644 or 0644 but most don't know why ? Here's why
Read or r has a positional weight of 4, Write or w has 2 and Execute or x has 1. Add them up for each group and you'll get the chmod number to use. For above example, the numbers will be (4+2)(4)(4) i.e. 644 or if you want four digits, use 0644 and that's pretty much it. It comes in very handy if you're learning shell scripting because Linux revolves around permissions. (Thanks to @MSF Jarvis)
Let's go trough basic shell commands. ​
If you interested about all commands, you can check them HERE.
cat [file destination] - use this command to print everything from a file to the terminal window
Example:
Open terminal window, and type next:
Code:
busybox cat /proc/meminfo [I](press enter)[/I]
You will get output after pressing enter
Now, you can see here, if you open any file manager and go to destination which was given for example "/proc/meminfo"
You will see next file and stuff inside it
Heheh, is it same?? ^~^ for sure that it is, you can use it for any file on your device which have text in it.
Let's go to the next basic command ^~^
echo - this command can be used for printing arguments to stdout. Also you can use it for adding text in already existing file which we need here, because we are learning scripting stuff, right? ^~^
Example:
Open terminal window, and type next:
Code:
busybox echo "Scripting is awesome" > /sdcard/test [I](press enter)[/I]
Ok, let's explain this.
First you added a command echo to add something in existing file, then between "..." we need to put arguments, for our case this is "Scripting is awesome" next we see symbol " > " which will forward arguments to next added direction, in our case this is "/sdcard/test".
First we need to have a existing file (IMPORTANT)
After we agreed with that we have a file
Open terminal as I already explained and after pressing enter you will get output on the terminal window.
That is a file from our /sdcard/
Don't delete this file, we will use it later with " sh" command.
Let's go to the next basic command
clear - Use this comand to clear whole terminal window.
Example:
You have a terminal window which have a lot of stuff on it, for example stuff from previous lines, text, etc.
You can simply make it blank with just one command
Code:
busybox clear [I](then press enter)[/I]
And voila, terminal window is blank
touch [file destination] - Use this command to create a blank file on any destination on your android device.
Example:
Open terminal window, and type next:
Code:
busybox touch /sdcard/scripting_007 [I](press enter)[/I]
This will create file called "scripting_007" on "/sdcard/" in this case, you can put any.
As you can see file "scripting_007" exist on /sdcard/
mkdir [file destination] - Use this command to create one empty folder on any destination on your android device.
Example:
Open terminal window, and type next:
Code:
busybox mkdir /sdcard/development [I](press enter)[/I]
This will create folder called "development" on "/sdcard/" in this case, you can put any.
sh [path of a file] - Use this command to execute basic script
Example:
Open terminal window, and type next:
Code:
sh /sdcard/test [I](press enter)[/I]
This will execute file which you make before with "echo" command
sleep [time in secs] - Use this command to make an offset between executing lines inside script.
Example:
Open terminal window, and type next:
Code:
busybox echo "Scripting is"
busybox sleep 10
busybox echo "awesome"
This is a combination of two commands as you can see, echo and sleep.
After launching this simple script in terminal window you will get first "Scripting is" and after 10 secs you will get awesome.
rm [ -f (file) -rf (folder)] - this is a command for removing files (-f) and folders (-rf)
Example:
Create a file called "android" on sdcard, then open terminal window, and type next:
Code:
busybox rm -f /sdcard/android
This simple code will remove a file called android from sdcard.
Now do the same thing with a folder, create one with the name "android" and run terminal emulator
Code:
busybox rm -rf /sdcard/android
This will remove folder called android from your sdcard.
Now, let's go with some advanced stuff​
You need any text editor, I suggesting this one
Link: Download from here
Now, open the app and write a new file and give it a name "test1"
Inside a file write next text:
Code:
busybox echo "Android"
busybox sleep 2
busybox echo "is"
busybox sleep 2
busybox echo "Awesome"
Save the file and copy it to some location, i suggest /sdcard/.
Open up terminal emulator and type next
Code:
sh /sdcard/test1 [I](press enter)[/I]
This thing will execute your script with the name test1 from /sdcard/.
Output will be "Android", then after two seconds will appear "is" and then after two more seconds "Awesome" will appear. THATS IT!!! You learned how to make a file (script) and how to execute it with terminal emulator.
Now do the same thing make a file with the name "test2" and make another file with a name "print"
First open "test1" and write next:
Code:
busybox echo "After 5 seconds"
busybox sleep 1
busybox echo "You will get a suprice"
busybox sleep 2
busybox clear
busybox echo "1"
busybox sleep 1
busybox clear
busubox echo "2"
busybox sleep 1
busybox clear
busybox echo "3"
busybox sleep 1
busybox clear
busybox echo "4"
busybox sleep 1
busybox clear
busybox echo "5"
busybox sleep 1
busybox clear
sh /sdcard/print
I think that you already know whats happened here
You have print, then you have sleep to make offset, and after that you have clear command to make window blank
Now open file with the name "print"
Inside it write next:
Code:
busybox echo "Voila, suprise"
Save this file, and open terminal emulator, and write next:
Code:
sh /sdcard/test2
And magic happens
In this example you learned how to execute second file with first, I think that it's not difficult for you
In this example we will play a bit with colors outputs
Codes for colors are below
Code:
busybox echo -e " 1. Black \e[0;100m \e[00;37;40m"
busybox echo -e " 2. Red \e[0;101m \e[00;37;40m"
busybox echo -e " 3. Green \e[0;102m \e[00;37;40m"
busybox echo -e " 4. Yellow \e[0;103m \e[00;37;40m"
busybox echo -e " 5. Blue \e[0;104m \e[00;37;40m"
busybox echo -e " 6. Purple \e[0;105m \e[00;37;40m"
busybox echo -e " 7. Cyan \e[0;106m \e[00;37;40m"
busybox echo -e " 8. White \e[0;107m \e[00;37;40m"
Try to copy this into terminal window and see what will happened or try whing which you learned before with the executing files. Copy whole code to a file and execute it with "sh" command. USE YOUR KNOWLEDGE.
Here you can see all things based on bash script coloring
https://wiki.archlinux.org/index.php/Color_Bash_Prompt
or
http://misc.flogisoft.com/bash/tip_colors_and_formatting
Here you can see all codes and it's nice descirbed.
Now, let's start
Make a file with the name "test3" open it and write or copy next code inside:
Code:
busybox echo " .... "
busybox echo " / / "
busybox echo " / / "
busybox echo " / / "
busybox echo " / /_._._. "
busybox echo -e " /_._._._._./ \e[00;41m SPEED MOD \e[00;37;40m v3.0"
busybox echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"
busybox echo -e "\e[01;32m Feel smoothness \e[00;37m"
busybox echo " "
As you can see this part was taken from mine L Speed performance/battery mod
Save the file, open terminal and type inside
Code:
sh /sdcard/test3
And you will get the same screen like in first L Speed menu.
Let's play a bit with this
You see the code
Code:
\e[00;41m SPEED MOD \e[00;37;40m v3.0
Just change one number instead of 41 write 42 and you will get green color, then give a try to other nubers. Every number is another color for example:
Code:
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
# Bold
BBlack='\e[1;30m' # Black
BRed='\e[1;31m' # Red
BGreen='\e[1;32m' # Green
BYellow='\e[1;33m' # Yellow
BBlue='\e[1;34m' # Blue
BPurple='\e[1;35m' # Purple
BCyan='\e[1;36m' # Cyan
BWhite='\e[1;37m' # White
# Underline
UBlack='\e[4;30m' # Black
URed='\e[4;31m' # Red
UGreen='\e[4;32m' # Green
UYellow='\e[4;33m' # Yellow
UBlue='\e[4;34m' # Blue
UPurple='\e[4;35m' # Purple
UCyan='\e[4;36m' # Cyan
UWhite='\e[4;37m' # White
# Background
On_Black='\e[40m' # Black
On_Red='\e[41m' # Red
On_Green='\e[42m' # Green
On_Yellow='\e[43m' # Yellow
On_Blue='\e[44m' # Blue
On_Purple='\e[45m' # Purple
On_Cyan='\e[46m' # Cyan
On_White='\e[47m' # White
# High Intensity
IBlack='\e[0;90m' # Black
IRed='\e[0;91m' # Red
IGreen='\e[0;92m' # Green
IYellow='\e[0;93m' # Yellow
IBlue='\e[0;94m' # Blue
IPurple='\e[0;95m' # Purple
ICyan='\e[0;96m' # Cyan
IWhite='\e[0;97m' # White
# Bold High Intensity
BIBlack='\e[1;90m' # Black
BIRed='\e[1;91m' # Red
BIGreen='\e[1;92m' # Green
BIYellow='\e[1;93m' # Yellow
BIBlue='\e[1;94m' # Blue
BIPurple='\e[1;95m' # Purple
BICyan='\e[1;96m' # Cyan
BIWhite='\e[1;97m' # White
# High Intensity backgrounds
On_IBlack='\e[0;100m' # Black
On_IRed='\e[0;101m' # Red
On_IGreen='\e[0;102m' # Green
On_IYellow='\e[0;103m' # Yellow
On_IBlue='\e[0;104m' # Blue
On_IPurple='\e[0;105m' # Purple
On_ICyan='\e[0;106m' # Cyan
On_IWhite='\e[0;107m' # White
On the next phase we will learn how to use variables, in bash scripts this is simple, just add a simple "tag" then what you want to connext wit this tag.
Here is an example:
Code:
file=/sdcard/test4
busybox touch $file
Ok, here is one simple thing, this is same like in touch command explaining, but there is a little difference. We added variable or you can call it shortcut if it's easier for you.
To call variable somewhere in a file you need to use a dollar sign "$" then name of your variable. Let's to next examole with variables.
As we now have file called test4 on our SD, we can go trough.
Code:
file=/sdcard/test4
busybox echo "hey file" > $file
As you can see everything is repeating from previous examples just with variable. This is much easier, and you will save a bit of time.
Now we can see what is inside file Open terminal emulator and type next
Code:
busybox cat /sdcard/test4
And you will get output "hey file"
Simple isn't it?
In this part we will learn how to use if, elif, else It's pretty simple, let's start.
Pattern for this will be:
Code:
if [what]; then
do something
fi
if [what]; then
do something
elif [what if not "if"]
do something
else
what to do else
fi
Ok what we have here?
The first part of code show us simple code which mean if for example something is true then do something and then close if with fi.
Second part of code is a bit "complicated". If somethig is true then do something, then we have elif, in case that if is false then it will do what is under elif. In case that both of them are false, everything what is under else will be executed.
Ok here is an example:
Code:
if [ -e /sdcard/test5 ]; then
busybox echo "hello" > /sdcard/test5
else
busybox touch /sdcard/test5
busybox echo "hello" > /sdcard/test5
fi
Ok, if file test 5 exists add hello to it, else(if not) then create a file and add text hello in it.
Another example with a bit of complications heheh
Code:
if [ -e /sdcard/test5 ]; then
busybox echo "file 5 exists"
elif [ -e /sdcard/test6 ]; then
busybox echo "file 6 exists"
else
busybox echo "files are not exist"
fi
Ok, here is explanation, if test5 exist then print "file 5 exists" going to the next line, if file test6 exist pri t "file 6 exists" and else if both of them doesn't exist print "files are not exist".
Donation:
http://forum.xda-developers.com/donatetome.php?u=5514152
Everyone who knows a bit of the performance/battery mods wants sometime to learn what is inside and how it's working
Here is a guide by @Paget96 (me) ^~^
As we know for every mod we need root, this is needed because we must to access to android shell.
init.d support, that is a folder which launch files from it on every boot. Init.d is included on some ROM's by default, but on some you need yo enable it by default(I will explain later how).
Next thing what you need is for sure busybox. And a little bit of free space on the /system partition.
Everyone knows how to root, I don't need to explain how to do that right?
User who doesn't have init.d will make it with next steps.
1. Flash superSU by @Chainfire (IMPORTANT)
2. In /system/etc/ make a file with the name "install-recovery-2.sh and push next code in it
Code:
#!/system/bin/sh
/system/bin/sysinit
3. Inside system/bin make a file with the name " sysinit" and push next code in it
Code:
#!/system/bin/sh
busybox sleep 30
export PATH=/sbin:/system/sbin:/system/bin:/system/xbin
run-parts /system/etc/init.d
4. Open /system/etc and make folder with the name "init.d"
Now you need to set permissions for all of this files.
Open terminal emulator and do next:
Code:
su
This will give root access
Code:
busybox chmod 755 /system/etc/install-recovery-2.sh
busybox chown 0.2000 /system/etc/install-recovery-2.sh
With this you will set "executable" permissions.
And we need permission for sysinit
Code:
busybox chmod 755 /system/bin/sysinit
busybox chown 0.2000 /system/bin/sysinit
And that's it
To install busybox use app "busybox installer" by stericson from playstore.
***IMPORTANT*** Don't change too much things, because you will get crap in your hands
Tools which are needed is
Text editor, I suggest Turbo Editor
Terminal emulator
ES file explorer
Ok, let's start
We will start with virtual memory tweaking...
Open file manager and create one folder where you will build a mod.
Inside it we will create one file for beginning and call it "00sysmod"
Code:
#!/system/bin/sh
busybox chmod 644 /proc/sys/vm/*
busybox sysctl -e -w vm.dirty_background_ratio=3
busybox sysctl -e -w vm.dirty_ratio=15
busybox sysctl -e -w vm.swappiness=40
busybox sysctl -e -w vm.dirty_expire_centisecs=500
busybox sysctl -e -w vm.dirty_writeback_centisecs=3000
busybox sysctl -e -w vm.min_free_kbytes=4096
busybox sysctl -e -w vm.overcommit_memory=1
busybox sysctl -e -w vm.overcommit_ratio=75
busybox sysctl -e -w vm.page-cluster=0
busybox sysctl -e -w vm.panic_on_oom=0
Copy this inside file, save it and copy to init.d folder
After that set permissions to 755
Code:
busybox chmod 755 /system/etc/init.d/00sysmod
Let's explain every line:
First line is a header of every script.
Next line will change permissions (in this case read, write, read, read) of a files which are inside /proc/sys/vm/*. * means every file.
Everything below it are vm parameters.
vm.dirty_background_ratio
Contains, as a percentage of total available memory that contains free pages
and reclaimable pages, the number of pages at which the background kernel
flusher threads will start writing out dirty data.
The total avaiable memory is not equal to total system memory.
dirty_ratio
Contains, as a percentage of total available memory that contains free pages
and reclaimable pages, the number of pages at which a process which is
generating disk writes will itself start writing out dirty data.
The total avaiable memory is not equal to total system memory.
swappiness
This control is used to define how aggressive the kernel will swap
memory pages. Higher values will increase agressiveness, lower values
decrease the amount of swap. A value of 0 instructs the kernel not to
initiate swap until the amount of free and file-backed pages is less
than the high water mark in a zone.
The default value is 60.
dirty_expire_centisecs
This tunable is used to define when dirty data is old enough to be eligible
for writeout by the kernel flusher threads. It is expressed in 100'ths
of a second. Data which has been dirty in-memory for longer than this
interval will be written out next time a flusher thread wakes up.
dirty_writeback_centisecs
The kernel flusher threads will periodically wake up and write `old' data
out to disk. This tunable expresses the interval between those wakeups, in
100'ths of a second.
Setting this to zero disables periodic writeback altogether.
min_free_kbytes
This is used to force the Linux VM to keep a minimum number
of kilobytes free. The VM uses this number to compute a
watermark[WMARK_MIN] value for each lowmem zone in the system.
Each lowmem zone gets a number of reserved free pages based
proportionally on its size.
Some minimal amount of memory is needed to satisfy PF_MEMALLOC
allocations; if you set this to lower than 1024KB, your system will
become subtly broken, and prone to deadlock under high loads.
Setting this too high will OOM your machine instantly.
overcommit_memory
This value contains a flag that enables memory overcommitment.
When this flag is 0, the kernel attempts to estimate the amount
of free memory left when userspace requests more memory.
When this flag is 1, the kernel pretends there is always enough
memory until it actually runs out.
When this flag is 2, the kernel uses a "never overcommit"
policy that attempts to prevent any overcommit of memory.
Note that user_reserve_kbytes affects this policy.
DON'T CHANGE THIS VALUE, YOU WILL GET CRAP IN A HANDS, THIS IS JUST FOR INFO
overcommit_ratio
With this parameter you will set how much space will allocations use in physical RAM. (Percentage)
page-cluster
page-cluster controls the number of pages up to which consecutive pages
are read in from swap in a single attempt. This is the swap counterpart
to page cache readahead.
The mentioned consecutivity is not in terms of virtual/physical addresses,
but consecutive on swap space - that means they were swapped out together.
It is a logarithmic value - setting it to zero means "1 page", setting
it to 1 means "2 pages", setting it to 2 means "4 pages", etc.
Zero disables swap readahead completely.
panic_on_oom
This enables or disables panic on out-of-memory feature.
If this is set to 0, the kernel will kill some rogue process,
called oom_killer. Usually, oom_killer can kill rogue processes and
system will survive.
If this is set to 1, the kernel panics when out-of-memory happens.
If this is set to 2, the kernel panics compulsorily even on the
above-mentioned. Even oom happens under memory cgroup, the whole
system panics
In this part we will tweak kernel parameters
Open file manager as before and create a file with the name " 00kerneltweak"
Here we will use if statement, just for a little practise ^~^
Code:
if [ -e /proc/sys/kernel/shmmni ]; then
busybox echo "2048" > /proc/sys/kernel/shmmni
fi
if [ -e /proc/sys/kernel/shmall ]; then
busybox echo "1572864" > /proc/sys/kernel/shmall
fi
if [ -e /proc/sys/kernel/shmmax ]; then
busybox echo "33554432" > /proc/sys/kernel/shmmax
fi
if [ -e /proc/sys/kernel/msgmni ]; then
busybox echo "512" > /proc/sys/kernel/msgmni
fi
if [ -e /proc/sys/kernel/msgmnb ]; then
busybox echo "16384" > /proc/sys/kernel/msgmnb
fi
if [ -e /proc/sys/kernel/msgmax ]; then
busybox echo "8192" > /proc/sys/kernel/msgmax
fi
Copy this inside file, save it and copy to init.d folder
After that set permissions to 755
Code:
busybox chmod 755 /system/etc/init.d/00kerneltweak
Same as we learned before if file exist then do next
Let's explain this parameters:
shmall
The total amount of shared memory (in pages) which can be allocated on the system
shmmax
The maximum size of a shared memory segment (in pages)
shmmni
The maximum number of shared memory segments available on the system
msgmni
The number of IPC message queue resources allowed (by default, 16).
msgmnb
Defines the maximum size in bytes of a single message queue. The default value is 65536 bytes.
msgmax
The maxim...
Remove Google Play Services data
Code:
#!/system/bin/sh
mount -o remount,rw /data
busybox mount -o remount,rw /data
GSM=/data/data/com.google.android.gms
for i in $GSM
do
busybox rm -rf $i/*
done
make a file, and add this inside, like before
copy to /system/etc/init.d
set permissions to 755
Clear browser data
Code:
#!/system/bin/sh
mount -o remount,rw /data
busybox mount -o remount,rw /data
browser=/data/data/com.android.NAME_OF_THE_BROWSER
for i in $browser
do
busybox rm -rf $i/*
done
make a file, and add this inside, like before
copy to /system/etc/init.d
set permissions to 755
first write a name of the browser, some devices have chrome as a default, then name will be
com.android.chrome
I'm sure that its
com.android.browser for default one
Check that inside /data/data, then just change inside the script
Or you can use this package
Code:
#!/system/bin/sh
while true; do
mount -o remount,rw /data
busybox mount -o remount,rw /data
busybox echo -n "Enter a name of the browser: "
busybox read -r name
brw=/data/data/com.android.$name
if [ -d $brw ]; then
for i in $brw
do
busybox rm -rf $i/*
done
busybox echo "Clearing done"
busybox sleep 2
else
busybox echo "Browser doesn't exist, please type another one..."
busybox sleep 3
fi
done
Well, this for this file guide is different,
Call the file "ccleaner" copy it to /system/bin
Set permissions to 755 like before
Open terminal emulator
Code:
su
ccleaner
Thanks Man
Thanks @Paget96 for your Support Man It will help Many user to Learn From You :fingers-crossed::good:
And Am the First to Comment on your Forum
cheers:laugh:
axays said:
Thanks @Paget96 for your Support Man It will help Many user to Learn From You :fingers-crossed::good:
And Am the First to Comment on your Form [emoji14]
Click to expand...
Click to collapse
I hope so
This thread needs too much stuff here, I cannot finish it in one day
Sent from my Nexus 5 using Tapatalk
Wow Good Job and Good Luck @Paget96 Its willbe Awesome
Paget96 said:
I hope so
This thread needs too much stuff here, I cannot finish it in one day
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
I'm a fan of your L Speed Mod, and this tutorial clears up many things. Subscribing now for updates when you add more stuff here.
Sent from my HTC Desire 616 dual sim using Tapatalk
Evolutionzz said:
Wow Good Job and Good Luck @Paget96 Its willbe Awesome
Click to expand...
Click to collapse
Thank you mate ^~^
MSF Jarvis said:
I'm a fan of your L Speed Mod, and this tutorial clears up many things. Subscribing now for updates when you add more stuff here.
Sent from my HTC Desire 616 dual sim using Tapatalk
Click to expand...
Click to collapse
Heh fans everywhere ^~^ Yeah, but TUT is not finished this is maybe 20% of stuff which are need to be here
Sent from my Nexus 5 using Tapatalk
Guys, more stuff will come tomorrow
Sent from my Nexus 5 using Tapatalk
Paget96 said:
Thank you mate ^~^
Heh fans everywhere ^~^ Yeah, but TUT is not finished this is maybe 20% of stuff which are need to be here
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Just 20%!!!! I'm dying to see the rest....
Paget96 said:
Thank you mate ^~^
Heh fans everywhere ^~^ Yeah, but TUT is not finished this is maybe 20% of stuff which are need to be here
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Sent from my HTC Desire 616 dual sim using Tapatalk
MSF Jarvis said:
Just 20%!!!! I'm dying to see the rest....
Sent from my HTC Desire 616 dual sim using Tapatalk
Click to expand...
Click to collapse
Heheh, there will be whole stuff about scripting which I used for L Speed building
Sent from my Nexus 5 using Tapatalk
For now, I think that it's enough, if you have more request, type below
Also I want to see screenshots of your attempts
Sent from my Nexus 5 using Tapatalk
Hell yeah!! Awesome Guide my bro @Paget96 Fantastic! This what people wanted from a long time. Amazing.
Sent From dark_world through my Android One
dark_optimistic said:
Hell yeah!! Awesome Guide my bro @Paget96 Fantastic! This what people wanted from a long time. Amazing.
Sent From dark_world through my Android One
Click to expand...
Click to collapse
Thank you, this is why I created it
Sent from my Nexus 5 using Tapatalk
Paget96 said:
For now, I think that it's enough, if you have more request, type below
Also I want to see screenshots of your attempts
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
I borked my phone a bit (this is a non - rooted phone ) so I'll post screenshots later when I UN-bork it.
Sent from my HTC Desire 616 dual sim using Tapatalk
MSF Jarvis said:
I borked my phone a bit (this is a non - rooted phone ) so I'll post screenshots later when I UN-bork it.
Sent from my HTC Desire 616 dual sim using Tapatalk
Click to expand...
Click to collapse
What you mean with borked?? hehh
I'm waiting for your screenshots, just to see how users understood stuff ^~^
Sent from my Nexus 5 using Tapatalk
delete
Awesome work as usual :angel:
Black_Eyes said:
Awesome work as usual :angel:
Click to expand...
Click to collapse
Thank you
I just want to share mine experience with the users
And probably to teach someone
Sent from my Nexus 5 using Tapatalk
Paget96 said:
What you mean with borked?? hehh
I'm waiting for your screenshots, just to see how users understood stuff ^~^
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Borked means I changed my recovery and flashed a GB ROM instead of using my friends custom built CM 11 build. My trusty Tahr system also broke down, but I am resilient so I'll manage and you WILL see the screenshots before 5PM IST.[emoji16] [emoji16] [emoji16] [emoji6] [emoji6] [emoji6] [emoji6]
Sent from my HTC Desire 616 dual sim using Tapatalk

Categories

Resources