{script} self-repair important data - Android Software/Hacking General [Developers Only]

Hello my goal is to create a buckup/restore script that does the restore from a safe file on phone when some files are missing or damaged in some way .
So i need help to get it started
By my idea it should have already a prebuilt backup file from which it will restore missing files
So after flashing a zip or at boot it should always run and check if something is missing from specified location example system/etc/init.d
And when it finishes it should react if there are files that are missing or are damaged
For the files that miss that is simple but how to create a script that will check if the file is damaged
simple by checking it size
ok i know how this would work in theory but i dont know how to writte that kind of a script so please
help thank you i made a simple check files script here:
Code:
#!/system/bin/sh
clear
sleep 2
echo ""
echo "SPL ENGINE CORE is installed "
sleep 2
echo ""
echo "Checking for SPL ENGINE A.I. CORE ..."
sleep 1
if [ -e /system/spl_engine_1996 ]; then
echo ""
echo "SPL ENGINE CORE is installed..."
sleep 1
else
echo ""
echo "SPL ENGINE CORE binary was not found,please Re-flash SPL Transcender then try again!"
sleep 1
fi
but how to backup restore from backup folder if it is missing or damaged dont know please help me
this is an idea about a smart self repair script so dont abuse and help
latest code not working but an improvment i think
Code:
#!/system/bin/sh
clear
sleep 2
echo ""
echo "SPL ENGINE CORE is installed "
sleep 2
echo ""
echo "Checking for SPL ENGINE A.I. CORE ..."
sleep 1
if [ -e /system/spl_engine_1996 ]; then
echo ""
echo "SPL ENGINE CORE is installed..."
sleep 1
else
echo ""
echo "SPL ENGINE CORE binary was not found,please Re-flash SPL Transcender then try again!" then
cp ./system/data/secure/files/spl_engine_1996 ./system
sleep 1
fi
found the solution for the copying eror it gave its in this line
looks like this :
Code:
cp ./system/data/secure/files/spl_engine_1996 ./system
and it should look like this:
Code:
cp -rf ./system/data/secure/files/spl_engine_1996 ./system
Two more things left:
1.make it run at every boot or for at a specific time 3 days a week
2.make it check if files are damaged
theese two steps will make it like artificial inteligence
hi i made some changes but i keep running into erors
the script now looks like this
Code:
#!/system/bin/sh
clear
FILENAME=/system/spl_engine_1996
FILESIZE=$(stat -c%s "$FILENAME")
RIGHTFILESIZE=3821568
sleep 2
echo ""
echo "SPL ENGINE CORE is installed "
sleep 2
echo ""
echo "Checking for SPL ENGINE A.I. CORE ..."
sleep 1
if -d /system/spl_engine_1996 && [FILESIZE=$(stat -c%s "$FILENAME")];
if [ $FILESIZE == RIGHTFILESIZE ]; then
echo file is the right size $RIGHTFILESIZE
elsif
echo file is corrupt size is under $RIGHTFILESIZE kilobytes
fi
then
echo ""
echo "SPL ENGINE CORE is installed..."
sleep 1
else
echo ""
echo "SPL ENGINE CORE binary was not found,!"
cp -rf ./system/data/secure/files/spl_engine_1996 ./system
sleep 1
fi
i get two erors one is
HTML:
/system/bin/testres[31] [-d :not found
/system/bin/testres[31] [: RIGHTFILESIZE : unexpected operator/operand

Someone please help
Someone please help

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.

[BASH SCRIPT][UPDATED] Governor Switch Scripts from the Command Line

UPDATE: Govswitch.sh has received an upgrade and it can now automagically generate an init.local.rc.new which can be used to set a governor on start up. It will also generate the chosen governor specific script and place it in the /system/bin folder. Thank you Duffkitty for the idea!
Original Post:
In the spirit of Open Source, I've written a couple of scripts that I wanted to share with the community. These are meant for advanced users familiar with the *nix command line. I didn't want to buy SetCPU (yes, I'm cheap ) so I decided to automate the process through the Bash shell language. For those interested, I've written a couple of Bash scripts that allow you to switch CPU governors via the command line. One script generates single instance scripts (one per governor) that can be used in conjunction with GScript for single click governor shortcuts. These single instance scripts are also ideal for changing the governor at boot. The other is command line only and prompts the user to choose from the available governors on the system.
I got tired of having to type it all out so I scripted the process. I just wanted to share with everyone else. I'm also planning to write a watch script that changes to the powersave governor automagically if the battery gets low.
I hope someone finds these scripts useful. Please let me know if anyone finds any errors in the scripts.
These scripts are offered under the terms of the GPLv2. Please see:
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
You must have root to run these. Usage is detailed in the scripts.
Disclaimer:
You use this script at your own risk. There are no warranties or guarantees of functionality or safety implied or stated whatsoever.
If you do not know what this does, please do not use it.
Despite my harsh warning above, I've designed these scripts to be as failsafe as possible so that nothing is written if the user does not want changes or the governor being selected is already in use. I use these scripts all the time and I have tried to make them as user friendly as command line scripts can be.
Unzip the attached zip to your SD Card. It contains:
gpl-2.0.txt
Description: License file.
govscriptgen.sh
Description: This script generates a set of scripts, one per governor to '/sdcard/governors/'. If a governor is not available in the kernel, no script is generated for it. IE: You can't have ondemand on a kernel that only has interactive built in as the only governor. If you do happen to run a governor script for a governor that is not available, it will simply exit with an error message and no changes made.
Example:
Run:
Code:
bash /sdcard/govscriptgen.sh
Then:
Code:
bash /sdcard/governors/ondemand.sh
Code:
## This script is offered free for use and distribution under the terms and conditions
# in accordance with the GPLv2. For more inforation please visit:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
## Written by Alex Zaballa (8/23/2010) for use on Android OS.
#
## Description: This script is designed to facilitate CPU Governor switching from
# the Bash command line that comes with custom Android ROMs. It reads the governors
# available on the system generates a script per governor.
# This allows user selection and future automation through Bash.
# Running this script with preexisting scripts in the gen_path
# will automatically overwrite the preexisting scripts.
# If you are a Bash editor, rename/backup anything you want to keep.
#
## Usage:
# bash /yourpath/govscriptgen.sh
#
## For root users only.
#
## Disclaimer:
# You use this script at your *own risk*. There are no warranties or guarantees
# of functionality or safety implied or stated whatsoever.
# If you do not know what this does, please do not use it.
##
# User Editable: Change this variable to change the generation path.
# Please use quotes and end slash.
gen_path="/sdcard/governors/"
# What governors are available to us?
gov_list="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)"
# Create governor script folder if it does not exist.
if [ ! -e "${gen_path}" ]; then
mkdir ${gen_path}
fi
# Main loop
# Loop through the available governors.
for gov in ${gov_list}; do
# Concatenate path + filename.
script_name="${gen_path}${gov}.sh"
# Echo it all to script_name, rinse, repeat.
echo "Generating ${script_name} ..."
echo '## This script is offered free for use and distribution under the terms and conditions' > ${script_name}
echo '# in accordance with the GPLv2. For more inforation please visit:' >> ${script_name}
echo '## http://www.gnu.org/licenses/old-licenses/gpl-2.0.html' >> ${script_name}
echo '#' >> ${script_name}
echo '## Written by Alex Zaballa (8/23/2010) for use on Android OS.' >> ${script_name}
echo '#' >> ${script_name}
echo '## Description: This script is designed to facilitate CPU Governor' >> ${script_name}
echo '# switching from the Bash command line that comes with custom'>> ${script_name}
echo '# Android ROMs. The script name is generated from the available' >> ${script_name}
echo '# governors and when run, updates to the governor for which the script' >> ${script_name}
echo '# is named. If a governor is not available, it will exit safely with an error.' >> ${script_name}
echo '# These scripts can be used with GScript to create governor shortcuts.' >> ${script_name}
echo '#'
echo '## Usage:' >> ${script_name}
echo "# bash ${script_name}" >> ${script_name}
echo '#' >> ${script_name}
echo '## For root users only.' >> ${script_name}
echo '#' >> ${script_name}
echo '## Disclaimer:' >> ${script_name}
echo '# You use this script at your *own risk*. There are no warranties or guarantees' >> ${script_name}
echo '# of functionality or safety implied or stated whatsoever.' >> ${script_name}
echo '# If you do not know what this does, please do not use it.' >> ${script_name}
echo '##' >> ${script_name}
echo "" >> ${script_name}
echo "" >> ${script_name}
echo '# Set governor that the script controls. This was given at generation.' >> ${script_name}
echo -e 'gov='"\042"${gov}"\042" >> ${script_name}
echo '# What is the current system governor?' >> ${script_name}
echo -e current_gov="\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)'"\042" >> ${script_name}
echo '# What governors are available to us?' >> ${script_name}
echo -e gov_list="\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)'"\042" >> ${script_name}
echo "" >> ${script_name}
echo '# Failsafe: If the governor we are trying to set to is not available, exit safely.' >> ${script_name}
echo 'if [ "$(echo "${gov_list}" | grep -c "${gov}" )" != "0" ]; then' >> ${script_name}
echo '# Failsafe: If the governor we are trying to set to is already set, write nothing.' >> ${script_name}
echo ' if [ "${gov}" != "${current_gov}" ]; then' >> ${script_name}
echo ' echo "${gov}" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' >> ${script_name}
echo ' current_gov="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"' >> ${script_name}
echo ' echo "Governor changed to:[${current_gov}]"' >> ${script_name}
echo ' else' >> ${script_name}
echo ' echo "Governor already set to:[${current_gov}]"' >> ${script_name}
echo ' echo "No changes made."' >> ${script_name}
echo ' fi' >> ${script_name}
echo 'else' >> ${script_name}
echo ' echo "Error: [${gov}] governor is not available on this kernel. No changes made."' >> ${script_name}
echo 'fi' >> ${script_name}
done
govswitch.sh
Description:
This script is meant for interactive terminal use (IE: use if you are staring at a command line prompt). It prompts the user for governor selection.
Example:
Run:
Code:
bash /sdcard/govswitch.sh
Code:
## This script is offered free for use and distribution under the terms and conditions
# in accordance with the GPLv2. For more inforation please visit:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
##
## Written by Alex Zaballa (8/23/2010) for use on Android OS.
##
# Description: This script is designed to facilitate CPU Governor switching from
# the Bash command line that comes with custom Android ROMs. It reads the governors
# available on the system and asks the user which they would like to use.
#
## Usage:
# bash /yourpath/govswitch.sh
#
## For root users only.
#
## Disclaimer:
# You use this script at your *own risk*. There are no warranties or guarantees
# of functionality or safety implied or stated whatsoever.
# If you do not know what this does, please do not use it.
##
# No root, no go.
if [ "$(whoami)" != "root" ]; then
echo "ERROR: You do not have sufficient privileges to run this script."
echo "Please re-run with root privileges."
exit 1
fi
# Default paths. Most of these should not change unless AOS does.
gov_path="/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
available_path="/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
init_rc_path="/system/etc/init.local.rc"
bash_path="/system/xbin/bash"
# Recursive function to nag user for a sane and expected answer: (Y)(y) or (N)(n).
function yesno {
read -s -n 1 ans
case $ans in
# If the user has made a choice, update system variable and exit function and for loop.
Y|y) if [ "$2" == '/system/etc/init.local.rc' ]; then
# Do no harm. User has final say to replace 'init.local.rc'.
clear
echo "Setting system to rw permissions."
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# Backup the original init.local.rc file if one does not exist.
if [ ! -e "${init_rc_path}.bak" ]; then
echo "Generating $2.bak"
cat "${init_rc_path}" > "${init_rc_path}.bak"
fi
echo "Generating $2.new"
cat "$2" > "$2.new"
echo "$1" >> "$2.new"
else
echo "$1" > "$2"
echo "[$1] written to:"
echo "$2"
fi
break 2> /dev/null ;;
# If the user wants something else, skip current item listed.
N|n) echo "Not writing [$1]..."
if [ "$2" == '/system/etc/init.local.rc' ]; then
echo "Done."
exit 0
fi ;;
# Garbage answer in; sanity nag out. Recurse.
* ) echo "Please enter:[y/n]"
yesno "$1" "$2";;
esac
}
# What governors are available to us?
gov_list="$(cat "${available_path}")"
# Main Loop
clear
echo "Available governors:[${gov_list}]"
# Failsafe: If all answers are no, we don't change anything.
echo "Answer (n)o to every question to keep current governor."
# Loop through available options.
for gov in ${gov_list}; do
# What is our current governor?
current_gov="$(cat "${gov_path}")"
# Skip question if the current governor and our option is the same.
if [ "${gov}" != "${current_gov}" ]; then
echo "The current governor is:[${current_gov}]"
echo ""
echo "Change to:[${gov}][y/n]?"
yesno "${gov}" "${gov_path}"
fi
done
# Confirm what we've done.
current_gov="$(cat "${gov_path}")"
echo -e "\nThe current governor is:[${current_gov}]"
echo "Do you want to use this governor on startup?"
startup_script="$(echo -e '/system/bin/'"${current_gov}"'.sh')"
init_string="$(echo -e 'service gov_'"${current_gov} ${bash_path} ${startup_script}\n\t\t"'oneshot'"\n\n\n")"
yesno "${init_string}" "${init_rc_path}"
if [ ! -e "${startup_script}" ]; then
# Echo it all to startup_script.
echo "Generating ${startup_script} ..."
echo '## This script is offered free for use and distribution under the terms and conditions' > ${startup_script}
echo '# in accordance with the GPLv2. For more inforation please visit:' >> ${startup_script}
echo '## http://www.gnu.org/licenses/old-licenses/gpl-2.0.html' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Written by Alex Zaballa (8/23/2010) for use on Android OS.' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Description: This script is designed to facilitate CPU Governor' >> ${startup_script}
echo '# switching from the Bash command line that comes with custom'>> ${startup_script}
echo '# Android ROMs. The script name is generated from the available' >> ${startup_script}
echo '# governors and when run, updates to the governor for which the script' >> ${startup_script}
echo '# is named. If a governor is not available, it will exit safely with an error.' >> ${startup_script}
echo '# These scripts can be used with GScript to create governor shortcuts.' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Usage:' >> ${startup_script}
echo "# bash ${startup_script}" >> ${startup_script}
echo '#' >> ${startup_script}
echo '## For root users only.' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Disclaimer:' >> ${startup_script}
echo '# You use this script at your *own risk*. There are no warranties or guarantees' >> ${startup_script}
echo '# of functionality or safety implied or stated whatsoever.' >> ${startup_script}
echo '# If you do not know what this does, please do not use it.' >> ${startup_script}
echo '##' >> ${startup_script}
echo "" >> ${startup_script}
echo "" >> ${startup_script}
echo '# Set governor that the script controls. This was given at generation.' >> ${startup_script}
echo -e 'gov='"\042"${current_gov}"\042" >> ${startup_script}
echo '# What is the current system governor?' >> ${startup_script}
echo -e 'current_gov='"\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)'"\042" >> ${startup_script}
echo '# What governors are available to us?' >> ${startup_script}
echo -e 'gov_list='"\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)'"\042" >> ${startup_script}
echo "" >> ${startup_script}
echo '# Failsafe: If the governor we are trying to set to is not available, exit safely.' >> ${startup_script}
echo 'if [ "$(echo "${gov_list}" | grep -c "${gov}" )" != "0" ]; then' >> ${startup_script}
echo '# Failsafe: If the governor we are trying to set to is already set, write nothing.' >> ${startup_script}
echo ' if [ "${gov}" != "${current_gov}" ]; then' >> ${startup_script}
echo ' echo "${gov}" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' >> ${startup_script}
echo ' current_gov="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"' >> ${startup_script}
echo ' echo "Governor changed to:[${current_gov}]"' >> ${startup_script}
echo ' else' >> ${startup_script}
echo ' echo "Governor already set to:[${current_gov}]"' >> ${startup_script}
echo ' echo "No changes made."' >> ${startup_script}
echo ' fi' >> ${startup_script}
echo 'else' >> ${startup_script}
echo ' echo "Error: [${gov}] governor is not available on this kernel. No changes made."' >> ${startup_script}
echo 'fi' >> ${startup_script}
fi
echo ""
echo "***"
echo "WARNING:"
echo "CHECK init.local.rc.new for correctness"
echo "BEFORE overwriting the original."
echo "***"
echo "If you need a backup of the original,"
echo "init.local.rc.bak was created at runtime."
echo "Run the following or similar command"
echo "to overwrite init.local.rc in /system/etc/:"
echo ""
echo "cat init.local.rc.bak > init.local.rc"
Thanks downloading now.
duffkitty said:
Thanks downloading now.
Click to expand...
Click to collapse
Please let me know if you have any questions.
At first I got a yesno error but ran it with sh and not bash.
Working but I can't figure out gscript it sends out stderr's. I have the lite so dunno.
I'm guessing to start at boot I would need to edit a bit =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
At first I got a yesno error but ran it with sh and not bash.
Working but I can't figure out gscript it sends out stderr's. I have the lite so dunno.
I'm guessing to start at boot I would need to edit a bit =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Click to expand...
Click to collapse
I found this for running scripts at boot. It's a good place to start.
http://forum.xda-developers.com/showthread.php?t=690564&page=2
govscriptgen.sh
This script generates a set of scripts, one per governor. It's those scripts you would want to use at boot or in gscript. If you didn't change the location, and assuming that you could write to your SD Card, they should be located in '/sdcard/governors'. There will be one per available governor (this is dictated by the kernel configuration).
In GScript do the following:
1. Open GScript Lite.
2. Menu > Add Script
3. Name the script. Let's say Ondemand.
4. Check 'Needs SU?'
5. In the text box type (without quotes), 'bash /sdcard/governors/ondemand.sh'
6. Create a shortcut to that script and it will set the governor it is named for.
govswitch.sh
This one is for use in a terminal and prompts the user for the desired governor.
I think I figured out and was gonna post it but you already did thanks. I appreciate it.
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Added interactive.sh to /system/bin and fixed the permissions but I added
service gov_interactive /system/bin/interactive.sh
oneshot
To init.local.rc and it doesn't start... I can run it in terminal emulator with just interactive.sh though....
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
Added interactive.sh to /system/bin and fixed the permissions but I added
service gov_interactive /system/bin/interactive.sh
oneshot
To init.local.rc and it doesn't start... I can run it in terminal emulator with just interactive.sh though....
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Click to expand...
Click to collapse
I think it needs the interpreter in front of it. Could you try the following?
Code:
service gov_interactive /system/xbin/bash /system/bin/interactive.sh
zansatsu said:
I think it needs the interpreter in front of it. Could you try the following?
Code:
service gov_interactive /system/xbin/bash /system/bin/interactive.sh
Click to expand...
Click to collapse
That does it. I guess it doesn't automagically know it's bash =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
That does it. I guess it doesn't automagically know it's bash =P
Click to expand...
Click to collapse
I'm glad it worked. Yeah, Android's command line fought me most of the way until I learned to just call bash before running any scripts. I suspect it's probably because the command line on Android initializes in a relatively 'bare' state as compared to all of Linux's bells and whistles that I'm used to.
Let me know if you have any more questions.
zansatsu said:
I'm glad it worked. Yeah, Android's command line fought me most of the way until I learned to just call bash before running any scripts. I suspect it's probably because the command line on Android initializes in a relatively 'bare' state as compared to all of Linux's bells and whistles that I'm used to.
Let me know if you have any more questions.
Click to expand...
Click to collapse
Thanks for helping =) I wonder if its possible to add bsd style init scripts. I guess you don't actually need to change many services but an rc.conf file would be cool =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
Thanks for helping =) I wonder if its possible to add bsd style init scripts. I guess you don't actually need to change many services but an rc.conf file would be cool =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Click to expand...
Click to collapse
I started on Slackware and a '/etc/rc.d/rc.local' file would be really awesome. Slackware being one of the oldest distros (if not the oldest) is very similar to BSD. I've had to configure Slack many times, but once you did it was rock-solid.
Android feels more like Ubuntu in some ways and Red Hat in others, but a very slim version of either. I can't really explain it.
Anywho. Glad I could help.
Code:
## This script is offered free for use and distribution under the terms and conditions
# in accordance with the GPLv2. For more inforation please visit:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
## Written by Alex Zaballa (9/23/2010) for use on Android OS.
#
Click to expand...
Click to collapse
How did you write this script one month in the future?
Seriously....would this script be able to change kernel voltage from command line? Say changing from undervolted to regular voltage for certain tasks (like GPS nav for example), then switch back to undervolt for other usage? Is something like that even possible? I've seen a few others ask about something like that in other threads.
chromiumleaf said:
How did you write this script one month in the future?
Click to expand...
Click to collapse
I'm just that ahead of my time! ROFL
DOH!
I corrected and reposted the zip file.
chromiumleaf said:
Seriously....would this script be able to change kernel voltage from command line? Say changing from undervolted to regular voltage for certain tasks (like GPS nav for example), then switch back to undervolt for other usage? Is something like that even possible? I've seen a few others ask about something like that in other threads.
Click to expand...
Click to collapse
If there is a command line associated with it, I can write a script that can easily handle it. I haven't looked into the specifics on changing voltages...
TBH: That thought scares the bejeezuz out of me.
zansatsu said:
If there is a command line associated with it, I can write a script that can easily handle it. I haven't looked into the specifics on changing voltages...
TBH: That thought scares the bejeezuz out of me.
Click to expand...
Click to collapse
Check out this thread for some of the initial dev conversations on undervolting: http://forum.xda-developers.com/showthread.php?t=697286 Ironically, I think some of it started from the guy who dev'd setcpu. Might have some info in it that could help you figure some things out. I'd try to sum it up for you but that stuff is just a bit over my head
Decad3nce said:
Code:
/* MSM7201A Levels 3-6 all correspond to 1.2V, level 7 corresponds to 1.325V. */
enum {
VDD_0 = 0,
VDD_1 = 1,
VDD_2 = 2,
VDD_3 = 3,
VDD_4 = 4,
VDD_5 = 5,
VDD_6 = 6,
VDD_7 = 7,
VDD_END
};
Thanks to kleranc for idea.
Click to expand...
Click to collapse
These are kernel level calls that have to be compiled into the kernel. Unless they make this available as a system variable, like the governors are, I don't think changing the voltage from the command line is possible... or even safe. The governors are routines written to control different CPU modes of operation and are designed to be fairly safe to use in instances of power management. Adjusting the voltages from the command line would prove to be too close to suicidal because Bash can't operate at the speeds necessary to monitor voltage fluctations.
Example: We hit a voltage spike, which needs to be corrected in nanoseconds (billionth of a second), Bash would brick the phone by not responding until at least 50 milliseconds (thousandth of a second) later, if ever.
Now if they had modules written that the kernel had different voltage 'modes' and built-in safeties, then I wouldn't have a problem manipulating them from the command line. As it stands, I'll leave it to people who think in ARM Assembler, C, and C++. lol
However, I am taking script ideas, so feel free to suggest anything else you might think is useful.
No Hero gets left behind!
Sent from my FROYO HERO.
Govswitch.sh has received an upgrade and it can now automagically generate an init.local.rc.new which can be used to set a governor on start up. It will also generate the chosen governor specific script and place it in the /system/bin folder. Thank you Duffkitty for the idea!
zansatsu said:
Govswitch.sh has received an upgrade and it can now automagically generate an init.local.rc.new which can be used to set a governor on start up. It will also generate the chosen governor specific script and place it in the /system/bin folder. Thank you Duffkitty for the idea!
Click to expand...
Click to collapse
Awesome I'm not longer using CM for a daily and switched to Zen-ROM but may go back when a release happens. Niche audience for the script but its very helpful
Sent from my HTC Hero using XDA App

Mod close this please

Mod please close this thread .
Thank you
Regards,
ImbaWind
Haven't download it yet but I'm just curious. Is this a "sync" followed by echoing "3" to the drop_cache file?
Sent from my Nexus S using xda premium
kοng said:
Haven't download it yet but I'm just curious. Is this a "sync" followed by echoing "3" to the drop_cache file?
Sent from my Nexus S using xda premium
Click to expand...
Click to collapse
and followed by a echo 1 to let the system continue create caches
Should the terminal emulator typing repeat in every reboot (soft reset)?
imbawind said:
Adrenaline Shot
This script act like an adrenaline shot for your phone.
It helps you to clear your system cache, get more free ram for you and gravely boost your phone's performance !
Click to expand...
Click to collapse
sync;
sleep 1
echo "3" > /proc/sys/vm/drop_caches;
echo "1" > /proc/sys/vm/drop_caches;
sleep 1
echo " ** Turbo Boosted ** ";
Is that all?
Not new. This script persists already in a lot of ROMs and tweaks.
My engine flush script included with V6 SuperCharger... it haz...
{
"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"
}
Just type "flush" in terminal
And what's up with the naming?
There is a well known Adrenaline Shot script plus there is a certain 3G TurboCharger but anyway instead of using 2 names (?) you should call it "Adrenaline Boost" or something
jolas said:
Should the terminal emulator typing repeat in every reboot (soft reset)?
Click to expand...
Click to collapse
whenever u feel lag
alexdoux25 said:
sync;
sleep 1
echo "3" > /proc/sys/vm/drop_caches;
echo "1" > /proc/sys/vm/drop_caches;
sleep 1
echo " ** Turbo Boosted ** ";
Is that all?
Not new. This script persists already in a lot of ROMs and tweaks.
Click to expand...
Click to collapse
really ?0.0
for my device this script echo 3 drop cache is indeed included in many script but none of them works
zeppelinrox said:
My engine flush script included with V6 SuperCharger... it haz...
Just type "flush" in terminal
And what's up with the naming?
There is a well known Adrenaline Shot script plus there is a certain 3G TurboCharger but anyway instead of using 2 names (?) you should call it "Adrenaline Boost" or something
Click to expand...
Click to collapse
okay I'll make changes
but I really don't know tat ur v6 can clear ram by terminal..
and isit ur script only echo 3 without echo 1 back and sync
correct me if i'm wrong
zeppelinrox said:
My engine flush script included with V6 SuperCharger... it haz...
Just type "flush" in terminal
And what's up with the naming?
There is a well known Adrenaline Shot script plus there is a certain 3G TurboCharger but anyway instead of using 2 names (?) you should call it "Adrenaline Boost" or something
Click to expand...
Click to collapse
Code:
if [ "$opt" -eq 16 ]; then
# see http://www.droidforums.net/forum/liberty-rom-d2/122733-tutorial-sysctl-you-guide-better-preformance-battery-life.html
# credit imoseyon
echo " Your device may get laggy after a day or two.."
echo ""
$sleep
echo " ...if you haven't rebooted."
echo ""
$sleep
echo " It happens when system caches keep growing..."
echo ""
$sleep
echo " ...and free RAM keeps shrinking..."
echo ""
$sleep
echo " ...and apps are starved for memory!"
echo ""
$sleep
echo ""
$sleep
echo " This Engine Flush will give you a Quick Boost!"
echo ""
$sleep
echo " The system will drop all file system caches..."
echo ""
$sleep
echo " ...which means more free RAM and no lag!"
echo ""
$sleep
echo " ...so need to reboot!"
echo ""
$sleep
echo " Credit to imoseyon for making this known!"
echo ""
$sleep
echo " Continue and drop all file system caches?"
echo ""
$sleep
echo -n " Enter Y for Yes, any key for No: "
read flush
echo ""
echo $line
case $flush in
y|Y)sync; echo 3 > /proc/sys/vm/drop_caches
echo " Engine Flush Completed!"
echo ""
$sleep
echo " ...Enjoy Your Quick Boost :)";;
*)echo " File system caches were retained...";;
esac
echo $line
echo ""
$sleep
fi
do u mean this one ?
Code:
Code:
# sync
# echo 3 > /proc/sys/vm/drop_caches
That's it. Not much to see here. The first command writes any cache data that hasn't been written to the disk out to the disk. The second command tells the kernel to drop what's cached. Not much to it. This invalidates the write cache as well as the read cache, which is why we have the sync command first.
Click to expand...
Click to collapse
Source
and from my opinion , it's better to echo 1 back to drop_caches, cause the caches which are still in use may be cleaned whenever u go task manager and clear ram
correct me if i'm wrong
imbawind said:
Code:
if [ "$opt" -eq 16 ]; then
# see http://www.droidforums.net/forum/liberty-rom-d2/122733-tutorial-sysctl-you-guide-better-preformance-battery-life.html
# credit imoseyon
echo " Your device may get laggy after a day or two.."
echo ""
$sleep
echo " ...if you haven't rebooted."
echo ""
$sleep
echo " It happens when system caches keep growing..."
echo ""
$sleep
echo " ...and free RAM keeps shrinking..."
echo ""
$sleep
echo " ...and apps are starved for memory!"
echo ""
$sleep
echo ""
$sleep
echo " This Engine Flush will give you a Quick Boost!"
echo ""
$sleep
echo " The system will drop all file system caches..."
echo ""
$sleep
echo " ...which means more free RAM and no lag!"
echo ""
$sleep
echo " ...so need to reboot!"
echo ""
$sleep
echo " Credit to imoseyon for making this known!"
echo ""
$sleep
echo " Continue and drop all file system caches?"
echo ""
$sleep
echo -n " Enter Y for Yes, any key for No: "
read flush
echo ""
echo $line
case $flush in
y|Y)sync; echo 3 > /proc/sys/vm/drop_caches
echo " Engine Flush Completed!"
echo ""
$sleep
echo " ...Enjoy Your Quick Boost :)";;
*)echo " File system caches were retained...";;
esac
echo $line
echo ""
$sleep
fi
do u mean this one ?
Click to expand...
Click to collapse
Try this one
Code:
echo " Reported \"Free\" RAM = $ramreportedfree MB"
echo ""
busybox sync; echo 3 > /proc/sys/vm/drop_caches
sleep 3
echo 1 > /proc/sys/vm/drop_caches
ramused=$((`free | awk '{ print $3 }' | sed -n 2p`/1024))
ramkbytesfree=`free | awk '{ print $4 }' | sed -n 2p`
ramkbytescached=`cat /proc/meminfo | grep Cached | awk '{print $2}' | sed -n 1p`
ramfree=$(($ramkbytesfree/1024));ramcached=$(($ramkbytescached/1024));ramreportedfree=$(($ramfree + $ramcached))
echo $line
echo " ...RAM Stats AFTER Engine Flush"
Plus you ain't sleeping between the echo 3 and echo 1 - so sometimes that won't work.
zeppelinrox said:
Try this one
Code:
echo " Reported \"Free\" RAM = $ramreportedfree MB"
echo ""
busybox sync; echo 3 > /proc/sys/vm/drop_caches
sleep 3
echo 1 > /proc/sys/vm/drop_caches
ramused=$((`free | awk '{ print $3 }' | sed -n 2p`/1024))
ramkbytesfree=`free | awk '{ print $4 }' | sed -n 2p`
ramkbytescached=`cat /proc/meminfo | grep Cached | awk '{print $2}' | sed -n 1p`
ramfree=$(($ramkbytesfree/1024));ramcached=$(($ramkbytescached/1024));ramreportedfree=$(($ramfree + $ramcached))
echo $line
echo " ...RAM Stats AFTER Engine Flush"
Plus you ain't sleeping between the echo 3 and echo 1 - so sometimes that won't work.
Click to expand...
Click to collapse
wow i din noticed that u hav new version , still can report ram free , awesome one of the best devs out there
thanks for your guidance
zeppelinrox said:
Try this one
Code:
echo " Reported \"Free\" RAM = $ramreportedfree MB"
echo ""
busybox sync; echo 3 > /proc/sys/vm/drop_caches
sleep 3
echo 1 > /proc/sys/vm/drop_caches
ramused=$((`free | awk '{ print $3 }' | sed -n 2p`/1024))
ramkbytesfree=`free | awk '{ print $4 }' | sed -n 2p`
ramkbytescached=`cat /proc/meminfo | grep Cached | awk '{print $2}' | sed -n 1p`
ramfree=$(($ramkbytesfree/1024));ramcached=$(($ramkbytescached/1024));ramreportedfree=$(($ramfree + $ramcached))
echo $line
echo " ...RAM Stats AFTER Engine Flush"
Plus you ain't sleeping between the echo 3 and echo 1 - so sometimes that won't work.
Click to expand...
Click to collapse
the line which shows ram doesnt works
Works in my screen shot, no?
I just posted a snippet LOL
imbawind said:
wow i din noticed that u hav new version , still can report ram free , awesome one of the best devs out there
thanks for your guidance
Click to expand...
Click to collapse
Thanks I appreciate the good words

[SCRIPT][v1.4]Bug Reporter (ultimate debugging) -- The MUST debugging AIO tool!

Greetings
Hello everyone, I made a script to help developers solve problems and you become a more helpful user.
What does it do?
It exports to sdcard :
dmesg
last_kmsg
wakelocks
kernel version
logcat (normal and long)
radio (aka modem log)
getprop (aka build.prop)
running processes
partition info
mount info
RAM info
interrupts
boot logs from kernels like : nAa, lupus
Total maximum possible logs are 14 files.
What should I do? :cyclops:
Send files from the folder with the time-stamp you have just created or send the tar.gz'ed file to the corresponding developer to help him. Each time you run the script it creates a different folder with a unique time-stamp of the time and date you dumped the logs.
Send whatever is needed, everything is in bug_reporter folder.
Ok, how do we install this thing?
Make sure you download the latest version [ v1.4 is the latest ] which is attached below and put it in your sdcard...and that your device is rooted.
Go to CWM recovery and flash it! It does no harm, it just copies a small 6kb file in your /system/xbin. So there is no need to uninstall it later. It will accompany you until you flash a new ROM.
If you are coming from another version, just flash it over.
If you are having any problems, first attach the debug.txt from bug_reporter folder and tell me your device, kernel and ROM. The problem might be your busybox installation though.
Ok, how do we use this thing?
Make sure you have a terminal app, I use this : https://play.google.com/store/apps/details?id=jackpal.androidterm
Open a terminal app and just type :
Code:
su
bug
IT WON'T WORK PROPERLY IF NOT EXECUTED FROM /system/xbin/, SO IT MAY FAIL WITH SCRIPT MANAGER. TRY AND REPORT BACK TO ME.
That's it?
Yes. :good:
If you have any questions, feel free to ask anything. :highfive:
Any screenshots? :angel:
Yep.
{
"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"
}
I want to contribute/redistribute
Oh, please do! :victory: Spread it, mod it, rewrite it, make your own version, inform developers, tell ROM cookers to include it, do whatever you want with it, but please don't forget me...
Post any improvements or modifications for me here. :fingers-crossed:
Here is the "source code" of it:
Code:
#!/system/bin/sh
DIRECTORY="/sdcard/bug_reporter"
clear
#ROOT CHECK, FOR SCRIPT TO WORK ON ALL su VERSIONS
clear
echo "Checking root permissions..."
if [ "$(id)" != "uid=0(root) gid=0(root)" ];
then
echo " - Denied?"
echo " * Please accept superuser permission..."
echo " /!\ FIRST TYPE: su"
echo
exit
elif [ "$(id)" == "uid=0(root) gid=0(root)" ];
then
echo " - Granted! SU binary version : $(su -V)"
else
echo
echo " /!\ Some errors occured... Obviously..."
echo " * Run the script again."
echo " - Asking superuser permissions..."
echo " ( i ) If you see somewhere "root", we are OK,"
echo " else, we are NOT."
su
echo " Look at it :"
id
exit
fi
{
#CREATING THE NEST DIRECTORY
#
if [ ! -d "$DIRECTORY" ];
then
echo " - Directory not found.
echo " - Creating...
mkdir $DIRECTORY
echo " - Done!
else
echo " - Fatal error! Exiting...
exit
fi
#FOR DEBUGGING REASONS
#
echo " - SU binary version : $(su -V)"
#VACUUM
#
clear
##SETTING MAX MB
if [ ! -f $DIRECTORY/max_mb.txt ];
then
echo Logs can easily exceed over the size you can imagine.
echo So, I will ask you if you want me to delete them
echo in the future.
echo
echo "How many MB of logs do you want to keep?"
echo "(5 MB recommended)"
read keep
KEEP_KB=$(echo $(($keep*1024)) )
echo $KEEP_KB > $DIRECTORY/max_mb.txt
clear
fi
SIZE=$(du -s $DIRECTORY | cut -f1)
MAX_MB=$(cat $DIRECTORY/max_mb.txt)
MB=$(echo $(($SIZE/1024)) )
##CHECKING IF MAX MB ARE REACHED AND PROMPT
if [ "$SIZE" -ge "$MAX_MB" ];
then
echo Log files have reached the maximum size you have set.
echo Their size is around $MB MB.
echo
echo Do you want to clean all logs?
echo "(y = Yes, clean. n = No, reset max MB value)"
read clean
echo
if [ "$clean" == "y" ] || [ "$clean" == "Y" ] || [ "$clean" == "yes" ] || [ "$clean" == "YES" ];
then
rm -r $DIRECTORY
echo - Cleaned!
echo - Re-run the script to set again the max MB value.
echo - Bye!
exit
elif [ "$clean" == "n" ] || [ "$clean" == "N" ] || [ "$clean" == "no" ] || [ "$clean" == "NO" ];
then
rm $DIRECTORY/max_mb.txt
echo - Value reseted!
echo - Re-run the script to set again the max MB value.
echo - Continuing...
sleep 2
else
echo "/!\ Illegal character. Try again...";
sleep 1
exec bug
fi
fi
#PRECALCULATIONS FOR LOGCATING
#
ls dev/log > $DIRECTORY/devlog
MAIN=$(grep main $DIRECTORY/devlog)
RADIO=$(grep radio $DIRECTORY/devlog)
clear
DATETIME=$(date +%Y%m%d%H%M%S)
export DATETIME
echo " ,-------------, Everything is saved on sdcard"
echo " / [email protected] / under bug_reporter folder."
echo "/_____________/__,------,"
echo "| Bug reporter v1.4 / Remember the timestamp!"
echo "|_______________,-----' Format : yyyymmddhhmmss"
echo
echo "It exports and compresses as tarball the following :"
echo "* dmesg"
echo "* last_kmsg"
echo "* wakelocks"
echo "* kernel version"
echo "* logcat (normal and long)"
echo "* radio (aka modem log)"
echo "* getprop (aka build.prop)"
echo "* running processes"
echo "* partition info"
echo "* mount info"
echo "* RAM info"
echo "* interrupts"
echo "* boot logs from kernels like : nAa, lupus"
echo
cd $DIRECTORY
#TIMESTAMP WHICH IS THE FOLDER'S NAME WHERE THE FILES ARE SAVED ON EACH RUN
echo - report timestamp : $DATETIME
mkdir "$DATETIME"
echo - exporting...
#FOR DMESG
echo - dmesg
dmesg > $DIRECTORY/"$DATETIME"/dmesg.txt
echo - OK!
#FOR LAST_KSMG
#
echo - last_kmsg
if [ -f /proc/last_kmsg ];
then
cat /proc/last_kmsg > $DIRECTORY/"$DATETIME"/last_kmsg.txt
echo - OK!
else
echo " /!\ last_kmsg not found!";
fi
#FOR WAKELOCKS
#
echo - wakelocks
if [ -f /proc/wakelocks ];
then
cat /proc/wakelocks > $DIRECTORY/"$DATETIME"/wakelocks.txt
echo - OK!
else
echo " /!\ wakelocks not found!";
fi
#FOR KERNEL VERSION
#
echo - kernel version
if [ -f /proc/version ];
then
cat /proc/version > $DIRECTORY/"$DATETIME"/kernel.txt
uname -a >> $DIRECTORY/"$DATETIME"/kernel.txt
echo - OK!
else
echo " /!\ version not found!";
fi
#FOR LOLCATS
#
if [ "$MAIN" != "main" ] || [ "$RADIO" != "radio" ];
then
echo " /!\ main and radio logging aborted!";
echo "* I can't logcat properly, loggers may be disabled."
echo "- Your ROM's dev must have disabled it via a script."
echo " OR"
echo "- Loggers are disabled from kernel."
else
##MAIN
echo - logcat
logcat -d > $DIRECTORY/"$DATETIME"/logcat.txt
echo - OK!
echo - long logcat
logcat -v long -d > $DIRECTORY/"$DATETIME"/long_logcat.txt
echo - OK!
##RADIO
echo - radio
logcat -b radio -v time -d > $DIRECTORY/"$DATETIME"/radio.txt
echo - OK!
fi
#FOR GETPROP
#
echo - getprop
getprop > $DIRECTORY/"$DATETIME"/getprop.txt
echo - OK!
#FOR RUNNING PROCESSES
#
echo - processes
ps > $DIRECTORY/"$DATETIME"/processes.txt
echo - OK!
#FOR PARTITION INFO
#
echo - partition info
df > $DIRECTORY/"$DATETIME"/partitions.txt
echo - OK!
#FOR MOUNTS
#
echo - mount info
mount > $DIRECTORY/"$DATETIME"/mounts.txt
echo - OK!
#FOR RAM
#
echo - RAM info
free > $DIRECTORY/"$DATETIME"/ram.txt
echo - OK!
#FOR INTERRUPTS
#
echo - interrupts
cat /proc/interrupts > $DIRECTORY/"$DATETIME"/interrupts.txt
echo - OK!
##----DEVIDER FOR SPECIAL LOGS----##
#BOOT LOG FOR nAa KERNELS AND DERIVATIVES
#
if [ -f "/boot.txt" ];
then
echo " ( i ) Oh, I found a boot log too!"
echo "- That's found on some nAa kernels, backing it up."
cat /boot.txt > $DIRECTORY/"$DATETIME"/boot.txt
echo - OK!
fi
#BOOT LOG FOR lupus KERNELS AND DERIVATIVES
#
if [ -f "/tmp/lupus.log" ];
then
echo " ( i ) Oh, I found a boot log too!"
echo "- That's found on some lupus kernels, backing it up."
cat /tmp/lupus.log > $DIRECTORY/"$DATETIME"/boot.txt
echo - OK!
fi
##----###----##
#CLEANING UP UNEEDED FILES FOR USER
#
echo - Cleaning up...
##CLEANING LAST TARBALL
rm *.tar.gz 2>&1 | >$DIRECTORY/devlog
##devlog IS A FILE OF PRECALCULATIONS FOR LOGCAT
if [ -f "$DIRECTORY/devlog" ];
then
rm $DIRECTORY/devlog
fi
#COMPRESSING FOR EASY SENDING
#
echo - Compressing logs...
echo - Done!
echo " ( i ) Send "$DATETIME".tar.gz to developer(s)!"
tar -zcf "$DATETIME".tar.gz "$DATETIME"
echo - Exiting...
#ADVERTISING THE SCRIPT
#
echo "http://forum.xda-developers.com/showthread.php?p=41107818" > $DIRECTORY/"$DATETIME"/"I used bug_reporter script.txt"
#DEBUGING MY SCRIPT
#
} 2>&1 | tee $DIRECTORY/debug.txt
exit
CHANGELOG
Code:
[B]v1.4[/B] [B][COLOR="Red"]MORE FEATURES[/COLOR][/B]-[COLOR="SeaGreen"]WORKS ON ALL SUPERUSER APPS[/COLOR]
- alternative root check
- now it's [B]not[/B] necessary to have SuperSU, you can use whatever you want, but you have to type [B]su[/B] first
- added additional logging of : [B]running processes[/B], [B]partition info[/B], [B]mount info[/B], [B]RAM info[/B], [B]interrupts[/B], [B]boot logs[/B] from [B]lupus[/B] kernel
- avoided potential bug with radio logging
- added some more info about kernel version logging (with [B]uname -a[/B] command)
- code clean up and more easier to follow
- faster? (it takes 1 second for me)
[B]v1.3[/B] [B][COLOR="Red"]ROCK STABLE[/COLOR][/B]-[COLOR="SeaGreen"]THE BEST[/COLOR]
- corrected root check
- added compatibility with CM10.1, it uses an older version of su and the script will ask you to install SuperSU to update it
- corrected and re-ordered some text
- optimized script speed by removing unnecessary su requests (it just takes 3 secs to finish)
- added build.prop backup with getprop command, it will help devs understand more info about your situation
- added some sort of advertisement of the script, so that it'll become popular
- added compression of the last logging folder, so that you can easily send it to dev(s)
- added more info on the script, made more presentable and explanatory for those who are willing to modify it
[B]v1.2[/B] [B][COLOR="Red"]STABLE[/COLOR][/B]-[COLOR="SeaGreen"]FULLY TESTED[/COLOR]
- finally fixed logcat exporting, now it will work for sure, fully tested
- cleaned up the script a lot and made it simplier for reading
- added radio (aka modem log), wakelocks and kernel version logging
- fixed terminal output logging for debugging better
[B]v1.1[/B] [I][COLOR="Gray"]it won't logcat, but everything else works[/COLOR][/I]
- fixed wrong logcat exporting, now when it's disabled, you'll know it
- added an auto-check for vaccuming logs after reaching above the MB size you set (logs can easily reach 10 MB)
- small bugfixes
- root check, in order to be sure we collect logs as root
- terminal output logging for debugging reasons
[B]v1.0 beta[/B] [I][COLOR="Gray"]works, but has many errors, it may even fail to flash.[/COLOR][/I]
- initial release
Thank you very much, this script will help a lot of people, including me
Sent from my R800i using xda premium
Is it possible to move this bug file to system/xbin instead of flashing it (gives error). And if yes, what should be the permissions?
zadrozny91 said:
Is it possible to move this bug file to system/xbin instead of flashing it (gives error). And if yes, what should be the permissions?
Click to expand...
Click to collapse
It's fixed. Just flash bug_reporter[v1.0]-nAa.zip, the permissions are 755. If you are unsure about permissions, see this : http://www.draac.com/chmodchart.html
But I am telling you to flash the fixed zip, it'll work.
leajian said:
It's fixed. Just flash bug_reporter[v1.0]-nAa.zip, the permissions are 755. If you are unsure about permissions, see this : http://www.draac.com/chmodchart.html
But I am telling you to flash the fixed zip, it'll work.
Click to expand...
Click to collapse
nice concept ,,but there are some problems
after taking log
both lastkmsg and logcat file show nothing(empty files)
long logcat shows this: 9 com.android.settings
only dmesg is correctly extracted
UPDATE!
Code:
[B]v1.1[/B]
- fixed wrong logcat exporting, now when it's disabled, you'll know it
- added an auto-check for vaccuming logs after reaching above the MB size you set (logs can easily reach 10 MB)
- small bugfixes
- root check, in order to be sure we collect logs as root
- terminal output logging for debugging reasons
Thanks man, I was going to write something similar until I found this.
I cannot attest to the zip's functionality as I use it with script manager, but I can say version 1.0 worked perfectly (producing the three possible proper log files) for me. Version 1.1 not so much it tells me 'I can't logcat' when I clearly can; gl with your 'main not found' problem.
Also a suggestion maybe include in your zip a copy of the script that goes to /sdcard/ so the user can easily access it in order to facilitate using it as a widget.
defiant07 said:
Thanks man, I was going to write something similar until I found this.
I cannot attest to the zip's functionality as I use it with script manager, but I can say version 1.0 worked perfectly (producing the three possible proper log files) for me. Version 1.1 not so much it tells me 'I can't logcat' when I clearly can; gl with your 'main not found' problem.
Also a suggestion maybe include in your zip a copy of the script that goes to /sdcard/ so the user can easily access it in order to facilitate using it as a widget.
Click to expand...
Click to collapse
Indeed, logcating won't work no matter what. It's a bug. I am aware of it. I'll fix it today I guess along with some code cleanup and considering your suggestion.
Sent from my MT11i using xda premium
Code:
[B]v1.2[/B] [B][COLOR="Red"]STABLE[/COLOR][/B]-[COLOR="SeaGreen"]FULLY TESTED[/COLOR]
- finally fixed logcat exporting, now it will work for sure, fully tested
- cleaned up the script a lot and made it simplier for reading
- added radio (aka modem log), wakelocks and kernel version logging
- fixed terminal output logging for debugging better
Also v1.0 beta re-added in case you want it.
Might convert this to external scripts for windows and unix as well. Btw, why the root checker? If it needs to be in system/xbin then you already have root
Sent from my Nexus 7 using Tapatalk HD
cybojenix said:
Might convert this to external scripts for windows and unix as well. Btw, why the root checker? If it needs to be in system/xbin then you already have root
Sent from my Nexus 7 using Tapatalk HD
Click to expand...
Click to collapse
:victory: Yeah, do whatever you want with it!
About the root check... Have you ever thought of "just in case" case? Well sometimes sh!t happens... Like the 7+7=16 embarrassing situation on final exams for example.
Anyway, probably won't need this check on other unix systems... You'll need to start the script with
Code:
sudo -i
and remove any
Code:
su -c
in the script. Also some logging files are available only for android, like logcat and logcat radio. If you need any help with converting I can help you both for windows and unix, just PM me.
EDIT : Opss, root check is buggy, I've discovered it thanks to you! I'll upload a fixed minor revision later.
leajian said:
:victory: Yeah, do whatever you want with it!
About the root check... Have you ever thought of "just in case" case? Well sometimes sh!t happens... Like the 7+7=16 embarrassing situation on final exams for example.
Anyway, probably won't need this check on other unix systems... You'll need to start the script with
Code:
sudo -i
and remove any
Code:
su -c
in the script. Also some logging files are available only for android, like logcat and logcat radio. If you need any help with converting I can help you both for windows and unix, just PM me.
EDIT : Opss, root check is buggy, I've discovered it thanks to you! I'll upload a fixed minor revision later.
Click to expand...
Click to collapse
I mean set up a script to run from a pc to debug android. Let's you run it on non rooted devices (parts of it anyway)
It's quicker than getting a user to push and run via the android terminal (which not everyone has)
Easier to run via an adb interface which can be supplied, and implement an update script everyone is running the same version
Btw won't need help check my signature for the root scripts
Sent from my Nexus 7 using Tapatalk HD
UPDATE! The tool is now in a super stable state of development.
Code:
[B]v1.3[/B] [B][COLOR="Red"]ROCK STABLE[/COLOR][/B]-[COLOR="SeaGreen"]THE BEST[/COLOR]
- corrected root check
- added compatibility with CM10.1, it uses an older version of su and the script will ask you to install SuperSU to update it
- corrected and re-ordered some text
- optimized script speed by removing unnecessary su requests (it just takes 3 secs to finish)
- added build.prop backup with getprop command, it will help devs understand more info about your situation
- added some sort of advertisement of the script, so that it'll become popular
- added compression of the last logging folder, so that you can easily send it to dev(s)
- added more info on the script, made more presentable and explanatory for those who are willing to modify it
can i get permission for adding your script in my cm-10.1 for LG-P350 ?
PecanCM said:
can i get permission for adding your script in my cm-10.1 for LG-P350 ?
Click to expand...
Click to collapse
Says in the post you can. Just credit
Sent from my Nexus 7 using Tapatalk HD
Just sharing. I use this:
bugreport > /sdcard/bug_report_`date +"%Y%m%d-%H%M"`
You may want to incorporate it in some way.
Sent from my GT-I9100 using xda premium
RovG said:
Just sharing. I use this:
bugreport > /sdcard/bug_report_`date +"%Y%m%d-%H%M"`
You may want to incorporate it in some way.
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
Thanks, I'll have it in mind, the reason why I didn't do this before is that I wanted it to be simple and not so informative.
In next update I might add some colors too!
Anyway here is an update... :fingers-crossed:
Code:
[B]v1.4[/B] [B][COLOR="Red"]MORE FEATURES[/COLOR][/B]-[COLOR="SeaGreen"]WORKS ON ALL SUPERUSER APPS[/COLOR]
- alternative root check
- now it's [B]not[/B] necessary to have SuperSU, you can use whatever you want, but you have to type [B]su[/B] first
- added additional logging of : [B]running processes[/B], [B]partition info[/B], [B]mount info[/B], [B]RAM info[/B], [B]interrupts[/B], [B]boot logs[/B] from [B]lupus[/B] kernel
- avoided potential bug with radio logging
- added some more info about kernel version logging (with [B]uname -a[/B] command)
- code clean up and more easier to follow
- faster? (it takes 1 second for me)

Modifying a 2/2 XL script for the 4/4 XL

Hi all,
You may or may not already be familiar with it, but there was a very nice script created by Joseph Miller to install new factory images (with or without locking the device). What I would like to do is to see how much of the script can be migrated to work with Pixel 4/4 XL.
Based on your experience with updating your 4/4 XL, do you see anything in the deuce script for the Pixel 2 that would need to be revised for use on a Pixel 4?
I'm certainly willing to test on my own device and any feedback would be appreciated. (I am relatively new to the Pixel 4 XL but very familiar with the Pixel 2 XL.)
.sh version is below:
Code:
#!/bin/sh
echo "Welcome to Deuces Flashing Script!"
echo "v5.0-Linux"
#to create a log, run: "script -c ./deuce-flash-all-v5.0.sh logfile.log"
echo "Checking if Fastboot binary is accessible.."
if [ -f "fastboot" ];
then
echo "\033[32m fastboot binary exists in script directory.\033[0m"
fb="./fastboot"
else
echo "\033[33mfastboot binary does not exist in script directory\033[0m" >&2
command -v fastboot | ( read fb; echo "\033[33mFound $fb. Will try to use this.\033[0m" )
fb="fastboot"
fi
echo "Checking if Fastboot works correctly"
if $fb --version
then
echo "\033[32m fastboot returned a version, continuing..\033[0m"
else
echo "\033[31m fastboot not working correctly.\033[0m"
exit 1
fi
echo "Checking if device is detected via Fastboot."
if [ -z $($fb devices -l) 2> /dev/null ]
then
echo "\033[31mDevice not detected in fastboot.\033[0m"
exit 1
else
echo "\033[32m Device detected!\033[0m"
fi
echo "Insuring unzip package is installed and accessible"
if unzip 1> /dev/null
then
echo "\033[32m unzip detected!\033[0m"
else
echo "\033[31m unzip is not installed, or is not working correctly!\033[0m"
echo "\033[33mplease install via:\033[0m"
echo "\033[33msudo apt install unzip\033[0m"
echo "\033[33mor\033[0m"
echo "\033[33msudo yum install unzip\033[0m"
exit 1
fi
zipcount="$(ls *.zip 2>/dev/null | wc -l)"
if [ "${zipcount}" -eq 1 ]
then
zipname="$(ls *.zip)"
echo ""
echo "\033[32mImage to flash: ${zipname}\033[0m"
elif [ "${zipcount}" -gt 1 ]
then
echo "\033[31m More than 1 zip!\033[0m"
echo "\033[31mPlease have only 1 zip file in the script folder.\033[0m"
zipnames="$(ls *.zip)"
echo "\033[33m${zipnames}\033[0m"
exit 1
else
echo "no zip files!"
exit 1
fi
echo -n "Are you SURE you want to continue? (y/N) "
read answer1
if echo "$answer1" | grep -iq "^y" ;then
echo "\033[33mThis Tool will reformat partitions in your device!\033[0m"
echo "\033[33mIt will attempt to keep your user data!\033[0m"
echo "\033[33mData could be lost! - Use At Your Own Risk!\033[0m"
echo -n "Continue? (y/N) "
read answer2
if echo "$answer2" | grep -iq "^y" ;then
echo "Checking if bootloader is unlocked."
echo "Look at device to confirm if script is waiting..."
$fb flashing unlock
echo "There will be errors if already unlocked, ignore."
else
echo "Aborting..."
exit 1
fi
else
echo "Aborting..."
exit 1
fi
echo "extracting the main image zip..."
unzip -j -o ${zipname} -d _work/
echo "setting active partition slot to A"
$fb --set-active=a
echo "flashing bootloader & radio..."
$fb flash bootloader _work/bootloader*.img
rm -rf _work/bootloader*.img
$fb reboot-bootloader
sleep 5
$fb flash radio _work/radio*.img
rm -rf _work/radio*.img
$fb reboot-bootloader
echo "extracting secondary image zip..."
zipname2="$(ls _work/*.zip)"
unzip -j -o ${zipname2} -d _work/
mkdir _work/_ 2>/dev/null
mv _work/*_other.img _work/_/ 2>/dev/null
echo "setting active partition slot to B"
$fb --set-active=b
bimgs="$(ls _work/_/*.img)"
for bimg in $bimgs
do
part=$(ls _work/_/*_other.img | cut -d "_" -f3 | cut -d "/" -f2)
echo $part
$fb flash $part $bimg
rm -rf $bimg
done
rm -rf _work/_
echo "setting active partition slot to A"
$fb --set-active=a
aimgs=$(ls _work/*.img)
for aimg in $aimgs
do
part=$(echo $aimg | cut -d "/" -f2 | cut -d "." -f1)
echo $part
$fb flash $part $aimg
rm -rf $aimg
done
echo -n "\033[33mDo you want to format user data? (y/N) \033[0m"
read answer3
if echo "$answer3" | grep -iq "^y" ;then
echo "\033[33m!!!This will wipe all your data!!!\033[0m"
echo -n "\033[31mAre you SURE? (y/N) \033[0m"
read answer4
if echo "$answer4" | grep -iq "^y" ;then
echo "Formatting user data.."
$fb format userdata 2>/dev/null
$fb reboot-recovery 2>/dev/null
echo "\033[32mDone!\033[0m"
else
echo "\033[36mSkipped formatting userdata.\033[0m"
echo "\033[32mDone!\033[0m"
exit
fi
else
echo "\033[36mSkipped formatting userdata.\033[0m"
echo "\033[32mDone!\033[0m"
exit
fi
exit
.bat version is here.
Note: I recommend placing the latest flashboot somewhere in your $PATH and running the script from within the unzipped factory image folder (where you have also unzipped the image zip).
Edit: Updated deuce script to v5.0 (thanks quorn23!)
Just a heads up, you're using an older version of the script, see original thread https://forum.xda-developers.com/pixel-2-xl/development/tool-deuces-bootloop-recovery-flashing-t3704761
I haven't tested it yet, but the 5.0 apparently works with A10 skimming through the last few pages in the thread. Once the Kernel is updated with the new sources (dez broke face unlock) i might have a look. What i probably would do is prepatch the boot image with magisk, besides that i would assume it's pretty straight forward, as it's AOSP.
Edit: as context, i'm coming from the pixel 2xl as well, i generally been using the Deuce script to update the 2 XL, if i recall correctly the only change i made was to adapt it to flash TWRP as well, which is currently not needed as not available for the 4 XL. (Devs wife is pregnant, so he's busy with more important personal life stuff currenty)
quorn23 said:
What i probably would do is prepatch the boot image with magisk, besides that i would assume it's pretty straight forward, as it's AOSP.
Click to expand...
Click to collapse
Out of habit, I've always re-added magisk manually, but you're right, this will require some additional dance steps without twrp. What i like about the original sh script is that the core dependency (for most scenarios) is a recent fastboot.

Categories

Resources