Hi guyz, i need someone help me.
I need 2 read from logcat a specific line:
Code:
I/ActicityManager< 1782> Config Changed: { scale1.0 imsi=204/16 loc=nl_NL touch=3 [B][COLOR="Red"]keys=2/1/2[/COLOR][/B] nav=2/1orien=1 layout=17 uiMode=17 seq=20}
How can i do to compare the text on red, with some variable into a bash script ?
Thanks in advance
on linux
adb logcat | grep "yourtext"
shows only lines with the text specified
slade87 said:
on linux
adb logcat | grep "yourtext"
shows only lines with the text specified
Click to expand...
Click to collapse
thanks, but i need 2 compare on smartphone, its for keyboard fix, and go something like this:
K1= "keys=2/1/1"
K2="here it takes text from logcat"
if [ "$K1" = "$K2" ];
then
turn on lights
else
turn off lights
fi
Click to expand...
Click to collapse
try to take the event:
maybe this helps:
http://stackoverflow.com/questions/1068000/android-keyboard-event-handler
slade87 said:
try to take the event:
maybe this helps:
http://stackoverflow.com/questions/1068000/android-keyboard-event-handler
Click to expand...
Click to collapse
It's that java languaje ?, **** im confused
PD: Was android programmed in java?, i thought just softwares were programmed in java
Slade it is for keyboard light we need to read the logcat if the key lit is slight out keyboard light goes on
If the lit is out you get keys=2/1/2 so if the script can read that and then echo a 1 to the keylight file
Thats what we need
Sent from my U20i using XDA Premium App
slade see what we got
# keyboard in/out fix
dev=/sys/devices/platform/msm_pmic_misc_led.0
fich=/system/bin
if [ -e cat $fich/whereverlogtakesplace | tail "keys=2/1/1" ];
then
cat /dev/input/event0|read -n 4
echo 1 > $dev/brightness
sleep 1
else
echo 0 > $dev/brightness
sleep 1
fi
you need su priviliges
/system/bin/logcat
slade87 said:
you need su priviliges
/system/bin/logcat
Click to expand...
Click to collapse
You mean script goes something like this
# keyboard in/out fix
dev=/sys/devices/platform/msm_pmic_misc_led.0
fich=/system/bin
if [ -e cat $fich/logcat | tail "keys=2/1/1" ];
then
cat /dev/input/event0|read -n 4
echo 1 > $dev/brightness
sleep 1
else
echo 0 > $dev/brightness
sleep 1
fi
Click to expand...
Click to collapse
EDIT: Dont working, i need to fix, script is bad
EDIT: On /system/bin/logcat dont exist logs, i opened logcat, and no logs
do a cat on /system/bin/logcat in your terminal emulator
works for me
Put the script in /etc/init.d and put this above your script then a blank line and then your script
''#!/system/bin/sh'' without quotes ofc
And make sure permission is 777 or 755 (rwxrwxrwx or rwxr-xr-x)
And name it 00keyboard
And one more thing you are checking the logcat now and then check and read the event0
We found out reading the event0 wont work
So that line will **** up the script
Delete the line ''cat /dev/input/event0|read -n 4''
Sent from my U20i using XDA Premium App
owain94 said:
Put the script in /etc/init.d and put this above your script then a blank line and then your script
''#!/system/bin/sh'' without quotes ofc
And make sure permission is 777 or 755 (rwxrwxrwx or rwxr-xr-x)
And name it 00keyboard
And one more thing you are checking the logcat now and then check and read the event0
We found out reading the event0 wont work
So that line will **** up the script
Delete the line ''cat /dev/input/event0|read -n 4''
Sent from my U20i using XDA Premium App
Click to expand...
Click to collapse
Something like this:
'#!/system/bin/sh
# keyboard in/out fix
su
dev=/sys/devices/platform/msm_pmic_misc_led.0
fich=/system/bin
logcat > $fich/logcat.txt
if [ -e cat $fich/logcat.txt | tail "keys=2/1/1" ];
then
echo 1 > $dev/brightness
sleep 1
else
echo 0 > $dev/brightness
sleep 1
fi
Click to expand...
Click to collapse
sorry just type:
/system/bin/logcat | grep 'keys=2/1/1'
in your console
D4rKn3sSyS said:
#!/system/bin/sh
# keyboard in/out fix
dev=/sys/devices/platform/msm_pmic_misc_led.0/
fich=/system/bin/
if [ -e cat $fich/logcat | grep "keys=2/1/1" ];
then
echo 1 > $dev/brightness
sleep 9
else
if [ -e cat $fich/logcat | grep "keys=2/1/2" ];
then
echo 0 > $dev/brightness
sleep 9
fi
Click to expand...
Click to collapse
I think it need to look something like this?
Long sleep so it dont check it to often
And then loop the script so it keeps checking
Sent from my U20i using XDA Premium App
slade87 said:
sorry just type:
/system/bin/logcat | grep 'keys=2/1/1'
in your console
Click to expand...
Click to collapse
yah that works, but we need to make it working without console, on a batch script
last that i got
#!/system/bin/sh
#
# keyboard in/out fix
dev=/sys/devices/platform/msm_pmic_misc_led.0/
fich=/system/bin/
if [ -e cat $fich/logcat | grep 'keys=2/1/1' ];
then
echo 1 > $dev/brightness
sleep 9
else
if [ -e cat $fich/logcat | grep 'keys=2/1/2' ];
then
echo 0 > $dev/brightness
sleep 9
fi
Click to expand...
Click to collapse
Code:
#!/system/bin/sh
/system/bin/logcat | grep 'keys=2/1/1' > /sdcard/true.log
if [ -s /sdcard/true.log ]; then
echo 1 > /sys/devices/platform/msm_pmic_misc_led.0/brightness
rm /sdcard/true.log
sleep 1
else
echo 0 > /sys/devices/platform/msm_pmic_misc_led.0/brightness
sleep 1
fi
its a dirty hack but give it a try.
it checks wheter created file is greater than 0 bytes which it is if true.log was created.
it removes true.log if successfull.
This script runs once now dark so if u wanna check open the keyboard and do this in terminal
Adb shell
Sh ./system/etc/init.d/00keyboard
You need to add a loop if you wanna to check over and over again
But you need to add longer sleeps then so it would not eat battery the problem then is that it will not put keyboard light on when you slide the lid open but a couple seconds later
Sent from my U20i using XDA Premium App
it would need to run later so name it 91keyboard after sdcard is mounted.
slade87 said:
it would need to run later so name it 91keyboard after sdcard is mounted.
Click to expand...
Click to collapse
Ahh yes ofcourse sorry my bad
Sent from my U20i using XDA Premium App
owain94 said:
Ahh yes ofcourse sorry my bad
Sent from my U20i using XDA Premium App
Click to expand...
Click to collapse
Called it 91keyboard and then this is the actual code:
Code:
#!/system/bin/sh
#
#Keyboard light fix
/system/bin/logcat | grep 'keys=2/1/1' > /sdcard/true.log
if [ -s /sdcard/true.log ]; then
echo 1 > /sys/devices/platform/msm_pmic_misc_led.0/brightness
rm /sdcard/true.log
sleep 1
else
echo 0 > /sys/devices/platform/msm_pmic_misc_led.0/brightness
sleep 1
fi
Related
Hi All Dev's,
In all dev forums we generally face various challenges and as such need to ask users a lot of question's if you have done this or not etc.
I am thinking of creating a simple script which when run on the machine can give us all the details as much as required.
for example for my BT5 and ubuntu work i require output of following commands.
mount
which busybox
echo $PATH
busybox
need inputs from other developers what exact details do they require to debug so that we can make a custom debug script which we can ask user to run once and use that as input for all its queries.....
More i will keep on adding in here... need dev's input here.
Note to MOD : this thread is in Dev section coz work is going on i am working on script just crowdsourcing the content as i don't want to leave anything out....
u will need to check for the following most used commands:
Code:
cat /proc/mtd
which
busybox
mount
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
and so on...
u get the idea...
so u get most info related to the device... MTD blocks, busybox location, mount points, location & symlink info (if any) of most used commands
Thanks for the inital tips ... working in this as i needed it for BT thread thought i would crowdsource the idea.
ohk so here is what i am doing right now.
creating a simple script which will generate all the debug output and dump it in /sdcard/debug_log.txt
then we can ask use to upload this debug_log.txt for our debugging.
To All Dev,
please suggest anything else you need to check frequently which we can add in here.
Will be uploading first version in few minutes.
@DooMLorD : might need your help in creating a recovery zip file of it.
anantshri said:
...
@DooMLorD : might need your help in creating a recovery zip file of it.
Click to expand...
Click to collapse
ya sure let me know...
till then something for u to read/check for creating update.zip
http://forum.xda-developers.com/showthread.php?t=1041064
also some examples of update-script:
http://forum.xda-developers.com/showthread.php?p=13522506#post13522506
First Set of code file
@DooMLorD : shamelessly copied your script to check type of Recovery, although added a bit of my logic in.
Code:
# DEBUG Log generation script created by Anant Shrivastava
# known as anantshri in XDA forum
# credit goes to B,J,Z and other developers.
# any specific code taken from other dev's have credit in place.
# incase i missed something send me a PM and i will add it.
debug()
{
#general debug listing.
echo "********** BUSYBOX *****************"
which busybox
busybox
echo "********** MOUNT *******************"
mount
cat /proc/mtd
echo "*************Command Permissions***************"
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.id"
cat /system/build.prop | grep "ro.build.display.id"
cat /system/build.prop | grep "ro.build.version.incremental"
echo "************* KERNEL INFORMATION ****************"
uname -a
echo "************* DEFAULT PATH **********************"
echo $PATH
}
debug_bt()
{
echo "BackTrack Specific Log"
ls -l /sdcard/bt
}
chk_recovery()
{
#
# Script (v1) to check for type of Recovery
# by DooMLoRD
#
# For Xperia X10 users only
#
echo "Recovery disk's available"
if [ -e /system/bin/xrecovery.tar ]
then
echo "xRecovery FOUND!"
fi
if [ -e /system/recovtools/xrecovery.tar.gz ]
then
echo "FreeXperia Recovery FOUND! [TYPE 1]"
fi
if [ -e /system/recovery/recovery.tar.bz2 ]
then
echo "FreeXperia Recovery FOUND! [TYPE 2]"
fi
echo -n "Chargemon Configured Recovery : "
REC=`cat /system/bin/chargemon | grep tar | grep recovery | cut -f4 -d"/"`
if [ $REC == "xrecovery.tar" ]
then
echo "Xrecovery"
elif [ $REC == "xrecovery.tar.gz" ]
then
echo "FreeXperia Recovery"
elif [ $REC == "recovery.tar.bz2"]
then
echo "FreeXperia Recovery type 2"
fi
}
export LOG_FILE=/sdcard/debug_log.txt
echo "Creating DEBUG LOG please wait"
echo "Collection general information"
debug > $LOG_FILE 2>&1
echo "Checking Recovery installed on phone"
chk_recovery >> $LOG_FILE 2>&1
echo "Collecting BT specific information"
debug_bt >> $LOG_FILE 2>&1
I am right now just attaching the sh file we can add an icon on desktop using gscript lite.
Please suggest if anything i missed.
ooohhhh nice modular functions in shell script!!!
great will be using this trick later for some advance work...
btw do shell scripts allow for "include" commands/scripts
EDIT:
yups i was thinking of including grep code to search for exact "Active" recovery in chargmeon...
EDIT2:
Gscript is weird... the output for ur code will display on device screen:
stderr:
stderr:
stderr:
stderr:
....
lots of them too
DooMLoRD said:
ooohhhh nice modular functions in shell script!!!
great will be using this trick later for some advance work...
btw do shell scripts allow for "include" commands/scripts
EDIT:
yups i was thinking of including grep code to search for exact "Active" recovery in chargmeon...
EDIT2:
Gscript is weird... the output for ur code will display on device screen:
stderr:
stderr:
stderr:
stderr:
....
lots of them too
Click to expand...
Click to collapse
1) just pulling off old shell scripting tricks i used to use.
include bash do support need to check if android shell will support or not.
2) So your task half done...
3) Stderr is what i don't understand at all why they occur in gscript
anantshri said:
1) just pulling off old shell scripting tricks i used to use.
include bash do support need to check if android shell will support or not.
2) So your task half done...
3) Stderr is what i don't understand at all why they occur in gscript
Click to expand...
Click to collapse
u might also want to search for:
Code:
which
on FreeX10-beta4 its a part of busybox (symlinked to busybox)
also some additional stuff u might want to check from build.prop
Code:
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.version.sdk"
cat /system/build.prop | grep "ro.build.version.release"
cat /system/build.prop | grep "ro.product.model"
{
"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 think this is a great idea, as a standard user it will give me a chance to provide useful feedback (rather then just saying "that's a good idea!")
So, forgive me for my ignorance of development, but could you also use the routine to perform common tests. i.e, besides the bug reports are there other sub-routines that can be executed (harmlessly) to provide the dev's with additional info on the phones' make-up.
I suggest this assuming there are some common problems that could be identified by accessing additional date not currently found in the de-bug outputs..?
Hi All,
updated the script with some more codes ....
Please suggest if anything else is needed will try to see if i can make a flashable zip for this.
changelog
1)added logcat's for events main and radio. also added option to get stacktrace of dalvik.
EDIT : script updated.....
anantshri said:
Hi All,
updated the script with some more codes ....
Please suggest if anything else is needed will try to see if i can make a flashable zip for this.
changelog
1)added logcat's for events main and radio. also added option to get stacktrace of dalvik.
Click to expand...
Click to collapse
dude u posted output of script and not the updated script itself
@DooMLorD
thanks for pointing ... correct script updated....
Please check and suggest...
anantshri said:
@DooMLorD
thanks for pointing ... correct script updated....
Please check and suggest...
Click to expand...
Click to collapse
looking good so far....
few more sugestions:
dmesg
kmesg
last_kmesg
DooMLoRD said:
looking good so far....
few more sugestions:
dmesg
kmesg
last_kmesg
Click to expand...
Click to collapse
I DooMLoRD,
Checked about all three
dmesg gives runtime output of kerenel messages.
cat /proc/kmesg is a copy of dmesg output... with a twist. once cat /proc/kmesg is done the output goes out of file and it just keeps waiting for more input.
last_kmesg as i know is for the last session.
Script is done ... will just post the details. here.
Need your help in creating a zipable file for creating this script as a simple command on shell.
Version 1.0 debug script
Code:
# DEBUG Log generation script created by Anant Shrivastava
# known as anantshri in XDA forum
# credit goes to B,J,Z and other developers.
# any specific code taken from other dev's have credit in place.
# incase i missed something send me a PM and i will add it.
debug()
{
#general debug listing.
echo "********** BUSYBOX *****************"
which
which busybox
busybox
echo "********** MOUNT *******************"
mount
cat /proc/mtd
echo "*************Command Permissions***************"
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.id"
cat /system/build.prop | grep "ro.build.display.id"
cat /system/build.prop | grep "ro.build.version.incremental"
cat /system/build.prop | grep "ro.build.version.sdk"
cat /system/build.prop | grep "ro.build.version.release"
cat /system/build.prop | grep "ro.product.model"
cat /system/build.prop | grep "ro.modversion"
cat /system/build.prop | grep "ro.rommanager.developerid"
cat /system/build.prop | grep "ro.build.description"
cat /system/build.prop | grep "ro.build.fingerprint"
echo "************* KERNEL INFORMATION ****************"
uname -a
echo "************* DEFAULT PATH **********************"
echo $PATH
}
debug_bt()
{
echo "************* BackTrack Specific Log ************"
ls -l /sdcard/bt
ls -l /data/local/bt
ls -l `which bt`
ls -l `which stopbt`
ls -l `which startbt`
echo "************* VNC Config File *******************"
cat /data/local/bt/root/.vnc/xstartup
}
chk_recovery()
{
#
# Script (v1) to check for type of Recovery
# by DooMLoRD
#
# For Xperia X10 users only
#
echo "*********************** RECOVERY DETAILS ***************"
echo "Recovery disk's available"
if [ -e /system/bin/xrecovery.tar ]
then
echo "xRecovery FOUND!"
fi
if [ -e /system/recovtools/xrecovery.tar.gz ]
then
echo "FreeXperia Recovery FOUND! [TYPE 1]"
fi
if [ -e /system/recovery/recovery.tar.bz2 ]
then
echo "FreeXperia Recovery FOUND! [TYPE 2]"
fi
echo -n "Chargemon Configured Recovery : "
REC=`cat /system/bin/chargemon | grep tar | grep recovery | cut -f4 -d"/"`
if [ $REC == "xrecovery.tar" ]
then
echo "Xrecovery"
elif [ $REC == "xrecovery.tar.gz" ]
then
echo "FreeXperia Recovery"
elif [ $REC == "recovery.tar.bz2"]
then
echo "FreeXperia Recovery type 2"
fi
}
logcats()
{
echo "========== LOGCAT : MAIN ==================="
logcat -b main -d
echo "========== LOGCAT : EVENTS ================="
logcat -b events -d
echo "========== LOGCAT : RADIO =================="
logcat -b radio -d
echo "******** DALVIK STACK TRACE *********************"
cat `cat /system/build.prop | grep "dalvik.vm.stack-trace-file" | cut -f2 -d"="`
echo "******** Kernel Messages DMESG ******************"
dmesg
echo "******** LOG LAST KMESG *************************"
cat /proc/last_kmsg
}
export LOG_FILE=/data/local/debug_log.txt
echo "Creating DEBUG LOG please wait"
echo "Collection general information"
debug > $LOG_FILE 2>&1
echo "Checking Recovery installed on phone"
chk_recovery >> $LOG_FILE 2>&1
echo "Collecting BT specific information"
debug_bt >> $LOG_FILE 2>&1
echo "Collecting logcat's : main, events, radio + stack trace"
logcats >> $LOG_FILE 2>&1
Hello!
As some of you know, pvyParts and I have been working on a custom stock-based ROM, T.E.A.M., which was initially released as a themed ROM to offer transparency and replace the Theme Chooser that we haven't been able to port properly, giving endless options on custom backgrounds (since your wallpaper is the system background).
As the ROM evolved and custom kernels became available, I wanted to tweak it using init.d scripts.
As all good developers here do, I searched the Android Software and Hacking General section,
browsed other devices' forums and came up with some tweaks that were really good -on paper.
To my disappointment, most of these did not work.
And I am not saying this because I didn't "feel" a difference
or because I could not spread my X10's smoothness on a cracker.
There is actually a way to test if a script runs with no errors, a.k.a actually works.
Without further adieu, here is how:
1. Place the script you want to test (let's say test.sh)
in /system and give it all permissions,
either with Root Explorer or via adb:
Code:
adb shell chmod 777 /system/test.sh
NOTE: Sometimes scripts don't have an extension (sh).
It's OK, you can still test it with this method.
2. Now install an app like Script Manager and run the script.
Or, do it via adb:
Code:
adb shell sh /system/test.sh
3. Now there are 3 things you might face:
- If you get an error in return, it means the script doesn't work,
so no point in placing it in init.d and running it at every boot, right?
- Some scripts include debug, so you may get a message saying Done, Success, or whatever, which means you are good to go.
- You might not get any output at all, but still that means the script ran fine.
For the latter two cases, you can safely run the script at boot by placing it in init.d folder.
The reason this thread is in development, is because I feel that since the X10 is getting old and many developers have left,
(but luckily new ones still appear, which is plainly AWESOME ), quality of ROMs is very important.
We have fewer choices, so let's make them worthwhile!
Doing it right now.
BTW- I'm first! Again!
Prodigy said:
Doing it right now.
BTW- I'm first! Again!
Click to expand...
Click to collapse
Let us know how it went!
its good to see dev sharing their dev knowledge and skills. this will make more dev for x10. more dev, more improvement we can do on our phone. Thanks My Immortal / iridaki. you're awsome
Thank
cause script stress me well
Now i can see if work or not
X10-tripmiui,iris,00
so if my rom has a init.d folder, does it means it supports or run script (on init.d folder) at boot? is there a way to check if my rom has init.d support??
draiyan said:
so if my rom has a init.d folder, does it means it supports or run script (on init.d folder) at boot? is there a way to check if my rom has init.d support??
Click to expand...
Click to collapse
Yes, support at boot.
To my less knowledge, just look if there is a init. d folder in system/etc/
When you make an own rom check if the kernel you wanna use,has init. d support.
Hope I didn't talk crap and this is right
Sent from my X10i using Tapatalk
but im really confuse here, i found this script,
Code:
/etc/init.d/03sdcardspeedfix
at some line of this script, it reads;
READ_AHEAD_KB="2048"
Click to expand...
Click to collapse
i know some c++ programming, and from what i know the value 2048 is assigned to read_ahead_kb, so i assume its the same in android. BUT, after reboot, i jumped to
Code:
/sys/devices/virtual/bdi/179:0/read_ahead_kb
to found out that its still 128, then i started thinking that the script didnt run, but the dev says the rom is init.d supported.
is there a way to test if init.d is reallty working? like at terminal emulator?
sure man !
you have two way for run tweak
in install-recovery.sh
or ini.d folder
but for be sure
create a file in system/etc
name it "install-recovery.sh"
copy this in and give all permission.
#!/system/bin/sh
#Mount Points
busybox mount -o remount,rw,noatime,nodiratime / -t rootfs
busybox mount -o remount,rw,noatime,nodiratime /sys -t sysfs
busybox mount -o remount,rw,noatime,nodiratime /system
busybox mount -o remount,rw,noatime,nodiratime /data
busybox mount -o remount,rw,noatime,nodiratime /cache
#init.d support
busybox run-parts /system/etc/init.d
run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1
now put your tweak in ini.d folder and reboot
be carefull !
if you have zipalign tweak
this tweak kill all tweak at boot because it unmount partition
and make it r/o instead of r/w
well,
tweak cannot access system or data like VM or sdcard tweak like read-ahead kb 2048.
now go in data/local/tmp
and check the log
to see if all it ok
but if ini.d does not run,
you could
insert tweak in install-recovery.sh
like this
#!/system/bin/sh
#give system permissions
busybox mount -o remount,rw /system
chmod 777 /system
#init.d support
busybox run-parts /system/etc/init.d
run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1
#uncap fps
mount -t debugfs debugfs /sys/kernel/debug
echo '0' > /sys/kernel/debug/msm_fb/0/vsync_enable
#th config
echo '0' > /sys/kernel/debug/msm_fb/0/hw_vsync_mode
echo '0' > /sys/kernel/debug/msm_fb/0/sw_refreshing_enable
echo '2' > /sys/kernel/debug/msm_fb/0/ref_cnt
echo '8' > /sys/kernel/debug/msm_fb/0/backbuff
echo '6000' > /sys/kernel/debug/msm_fb/0/refx100
#echo '1' > /sys/power/wake_lock *dangerous
#echo '1' > /sys/kernel/debug/kgsl/cache_enable *dangerous
echo '8192' > /sys/block/mmcblk0/queue/read_ahead_kb
echo '128' > /sys/block/mmcblk0/queue/max_sectors_kb
echo '8192' > /sys/block/mmcblk1/queue/read_ahead_kb
echo '128' > /sys/block/mmcblk1/queue/max_sectors_kb
#rm -f -rf /data/idd
#rm -f -rf /data/semc-checkin
umount /sys/kernel/debug
echo 0 > /sys/kernel/logger/log_main/enable
echo 0 > /sys/kernel/logger/log_event/enable
echo 0 > /sys/kernel/logger/log_radio/enable
echo 1024 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo 1024 > /sys/devices/virtual/bdi/default/read_ahead_kb
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 30 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/down_differential
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load
# Delay the Media Scanner to help boot times
pm disable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &
sleep 80 && pm enable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &
#I/O Scheduler Tweaks
mount -o remount,noatime / -t rootfs
mount -o remount,noatime /dev -t devpts
mount -o remount,noatime /proc -t proc
mount -o remount,noatime /sys -t sysfs
mount -o remount,noatime /mnt/asec -t tmpfs
mount -o remount,noatime /system -t yaffs2
mount -o remount,noatime /data -t yaffs2
mount -o remount,noatime /cache -t yaffs2
mount -o remount,noatime /mnt/sdcard -t vfat
mount -o remount,noatime /mnt/secure/asec -t vfat
mount -o remount,noatime /mnt/sdcard/.android_secure -t tmpfs
i=`ls -d /sys/block/mtdblock3/queue/scheduler`;
STL=`ls -d /sys/block/stl*`;
BML=`ls -d /sys/block/bml*`;
MMC=`ls -d /sys/block/mmc*`;
TFSR=`ls -d /sys/block/tfsr*`;
DM=`ls -d /sys/block/dm*`;
MTD=`ls -d /sys/block/mtd*`;
LOOP=`ls -d /sys/block/loop*`;
RAM=`ls -d /sys/block/ram*`;
SYSDEV=`mount | grep '/system' | cut -d '/' -f 4`;
IO_SCHEDULER=`echo "noop" > /sys/block/mtdblock3/queue/scheduler/queue/rotational`;
for i in `busybox ls -1 /sys/block/mtdblock*`; do
echo "deadline" > $i/queue/scheduler;
done;
for k in $(busybox mount | cut -d " " -f3)
do
sync;
busybox mount -o remount,noatime,nodiratime $k;
done;
echo "deadline" > /sys/block/mmcblk0/queue/scheduler
echo "deadline" > /sys/block/dm-0/queue/scheduler
echo "deadline" > /sys/block/dm-1/queue/scheduler
for i in $MMC $MTD $LOOP; do
echo 0 > $i/queue/rotational;
done;
for i in $MMC $MTD; do
echo "deadline" > $i/queue/scheduler;
done;
for i in $MMC; do
echo 4096 > $i/queue/read_ahead_kb;
echo 0 > $i/queue/rotational;
echo 1 > $i/queue/iosched/low_latency;
echo 16 > $i/queue/iosched/quantum;
echo 8192 > $i/queue/nr_requests;
echo 1000000000 > $i/queue/iosched/back_seek_max;
for i in $STL $BML $MMC;
do
echo $IO_SCHEDULER > $i/queue/scheduler;
case $IO_SCHEDULER in
"deadline")
echo 1 > $i/queue/iosched/fifo_batch;;
"cfq")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
"bfq")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
"noop")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
esac;
done;
#Dalvik Cache
if [ ! -d /cache/dalvik-cache ]
then
busybox rm -rf /cache/dalvik-cache /data/dalvik-cache
mkdir /cache/dalvik-cache /data/dalvik-cache
fi
#Dalvik Cache
busybox chown 1000:1000 /cache/dalvik-cache
busybox chmod 0771 /cache/dalvik-cache
#bind mount dalvik-cache so we can still boot without the sdcard
busybox mount -o bind /cache/dalvik-cache /data/dalvik-cache
busybox chown 1000:1000 /data/dalvik-cache
busybox chmod 0771 /data/dalvik-cache
#Remove
busybox rm -rf /data/tombstones/*
#Zipalign
mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system
cd /system/app
for z in *.apk; do
zipalign -c 4 $z
if [ "$?" -ne "0" ]; then
echo zipalign $z !
zipalign -f 4 $z /tmp/$z
cp /tmp/$z $z
rm /tmp/$z
fi
done
mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system
mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data
cd /data/app
for z in *.apk; do
zipalign -c 4 $z
if [ "$?" -ne "0" ]; then
echo zipalign $z !
zipalign -f 4 $z /tmp/$z
cp /tmp/$z $z
rm /tmp/$z
fi
done
mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data
#Phone Lag Tweaks
MAX_PHONE() {
pidphone=`pidof com.android.phone`;
if [ $pidphone ]; then
echo -17 > /proc/$pidphone/oom_adj;
renice -20 $pidphone;
exit;
else
sleep 5;
MAX_PHONE;
fi;
}
(while [ 1 ]; do
sleep 10;
MAX_PHONE;
done &);
if [ $ENABLE_MAXPHONE -eq 1 ];
then
PROC_ADJUST "com.android.phone" "-20" &
fi;
for j in $DM $MTD $LOOP $RAM; do
echo 0 > $j/queue/rotational;
done;
strace -p $(pidof yourapp) # for all your running applications
ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time
#CPUTweak's Variables
last_source="unknown";
charging_source=$(cat /sys/class/power_supply/battery/charging_source);
capacity=$(cat /sys/class/power_supply/battery/capacity);
if [ $ENABLE_SWITCH -eq 1 ];
then
ALLFREQS=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`;
(while [ 1 ];
do
cat /sys/power/wait_for_fb_wake;
AWAKE_MODE;
cat /sys/power/wait_for_fb_sleep;
SLEEP_MODE;
done &)
fi;
BAT_SLEEP_GOV="powersave"
USB_SLEEP_GOV="powersave"
POW_SLEEP_GOV="powersave"
#CPUTweak's Functions
Battery() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $BAT_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 100 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $BAT_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3
}
USB() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $USB_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $USB_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
}
Power() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $POW_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $POW_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
}
#
# Loopy Smoothness Tweak for X10
#
for n in 1 2
do
USER_LAUNCHER="com.sonyericsson.home" # Change this to your launcher app
NUMBER_OF_CHECKS=35 # Total number of rechecks before ending 1st loop
SLEEP_TIME=3 # Number of seconds between rechecking processes
PROCESSES_TOTAL=4 # Must be edited to match the number of processes to be checked
DEBUG_ECHO=0 # Debug on/off
CHECK_COUNT=0 # Don't edit
P_CHECK=0 # Don't edit
CHECK_OK=0 # Unused
PROCESS_1=0; PROCESS_2=0; PROCESS_3=0; PROCESS_4=0; PROCESS_5=0; PROCESS_6=0;
PROCESS_7=0; PROCESS_8=0; PROCESS_9=0; PROCESS_10=0; PROCESS_11=0; PROCESS_12=0;
PROCESS_13=0; PROCESS_14=0; PROCESS_15=0; PROCESS_16=0; PROCESS_17=0; PROCESS_18=0;
PROCESS_19=0; PROCESS_20=0; PROCESS_21=0; PROCESS_22=0; PROCESS_23=0; PROCESS_24=0;
if [ $n -eq "1" ]; then
if [ $DEBUG_ECHO -eq "1" ]; then
echo ""
echo "LST Debug: $(date)"
echo "LST Debug: Initiate"
fi;
# Pause and then loop until kswapd0 is found, which should be instant anyway
sleep 1
SWAP_SLEEP_TIME=3; SWAP_NUMBER_OF_CHECKS=30; SWAP_CHECK_COUNT=0; SWAP_CHECK_COUNT_OK=0; while [ $SWAP_CHECK_COUNT -lt $SWAP_NUMBER_OF_CHECKS ]; do if [ `pidof kswapd0` ]; then renice 19 `pidof kswapd0`; SWAP_CHECK_COUNT=$SWAP_NUMBER_OF_CHECKS; SWAP_CHECK_COUNT_OK=1; else sleep $SWAP_SLEEP_TIME; fi; SWAP_CHECK_COUNT=`expr $SWAP_CHECK_COUNT + 1`; done; if [ $SWAP_CHECK_COUNT_OK -lt 1 ]; then echo "LST Debug: 'kswapd0' expired after `expr $SWAP_CHECK_COUNT \* $SWAP_SLEEP_TIME` seconds"; fi;
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: $(date)";
echo "LST Debug: kswapd0 found";
fi;
fi;
# Check briefly one more time
if [ $n -eq "2" ]; then
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: 2nd loop"
fi;
NUMBER_OF_CHECKS=6 # Editing not recommended
SLEEP_TIME=5 # Editing not recommended
fi;
while [ $CHECK_COUNT -lt $NUMBER_OF_CHECKS ];
do
# Resident system apps
if [ $PROCESS_1 -eq "0" ]; then PNAME="com.android.phone"; NICELEVEL=-20; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_1=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_2 -eq "0" ]; then PNAME="$USER_LAUNCHER"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_2=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_3 -eq "0" ]; then PNAME="com.sonyericsson.conversations"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_3=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_4 -eq "0" ]; then PNAME="com.sonyericsson.music"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_4=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
# If all processes are done, loop can finish early
if [ $P_CHECK -ge $PROCESSES_TOTAL ]; then CHECK_COUNT=$NUMBER_OF_CHECKS; else sleep $SLEEP_TIME; fi;
CHECK_COUNT=`expr $CHECK_COUNT + 1`;
done
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: $(date)"
if [ $PROCESS_1 -eq "0" ]; then echo "LST Debug: PROCESS_1 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_2 -eq "0" ]; then echo "LST Debug: PROCESS_2 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
echo "LST Debug: Checking complete"
fi;
done
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: Done"
echo ""
fi;
this is an exemple!
but you could use it !
it improve speed of your phone hahaha !!!
bip
i tried install-recovery but i got no file at local/temp??? there should be a log file in it rigth?
Another tip - add this command to the top of the script:
Code:
set -xv
This will give full command echoing when you run the script so you can see where the error is. The android shell doesn't report lines accurately, I think it's because it doesn't count comments as lines. It will also make easily visible syntax errors that dont error but cause a conditional to report incorrect, e.g. if you accidentally use == instead of = or forget double-quotes when comparing strings.
Okay, I see a lot of devs that want to put out a "rom", and I am trying to do that for all the roms- leaks, roms, etc. I think I can accomplish what most rom devs do with small flashable zips-- I just need this help to make it possible!
The only thing that is hanging me up is - change A to B, if A doesn't exist add B. I've done lots of googling, but the sed command seems REALLY complicated for what I am trying to do- and I think there must be an easier way people are already using for android! Or is there a program people are using to make these insanely complicated scrips I see?!?!
Here is an example I know I can do, and works- but it is modifying a line I know IS there:
Code:
sed 's/^ro.product.version=*/ro.product.version=Revolutionized Nonsense 2.1Final/g' /system/build.prop
Like as simple as changing my build, no problem, I know that build is there, but what if I want to change "ro.ril.gprsclass=10" to "ro.ril.gprsclass=12"- but if it ISN'T there, I want to add that line??(I'm not saying it ISN'T there, this is just an example..)
Like I said, I am sure there is a simpler way, I know SED allows patterns and all of that- I am trying to keep this simple! I don't want to replace someone's build.prop, I want to modify it(and I will make a backup)- and for all non RO(read only) lines I plan to use local.prop..
Please, I have asked a few questions here that never got answered, I eventually found a workaround, but this one has TRULY stumped me! This is all a learning process for me, and I am trying to learn the simplest/best way, not just the long and complicated way..
Thanks in advance!
SBD
So from my understanding, you are looking to write a script that modifies the build.prop, yes?
If so, you'd want to do something like this. This is pseudo-code!
if entry exists ; then
replace entry
else if entry does not exist ; then
add entry
fi
For your test, use grep.
if grep ro.sample.prop build.prop ; then
sed -d CODE HERE TO REPLACE
else
echo CODE HERE >> build.prop
fi
Please let me know if you need further help.
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
So from my understanding, you are looking to write a script that modifies the build.prop, yes?
If so, you'd want to do something like this. This is pseudo-code!
if entry exists ; then
replace entry
else if entry does not exist ; then
add entry
fi
For your test, use grep.
if grep ro.sample.prop build.prop ; then
sed -d CODE HERE TO REPLACE
else
echo CODE HERE >> build.prop
fi
Please let me know if you need further help.
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
So with my example above would this work??
Code:
if grep ro.ril.gprsclass= /system/build.prop ; then
sed 's/^ro.ril.gprsclass=*/ro.ril.gprsclass=12/g' /system/build.prop
else
busybox echo "ro.ril.gprsclass=12" >> /system/build.prop
Your example makes me wonder if sed gets use differently aftergrep(or is that formatted correctly?) and what is the -d for?
I need to do this with a lot of lines, so if this does work I need to make sure that the formatting is correct.. because I just want to make a file that works, not troubleshoot it a million times!(My luck I'd leave a space in it somewhere that screws it all up)..
I'm sorry if these questions seem ridiculous, but this will help me get done what I am trying to do - I've already learned so much java, scripting, coding, unix- I don't even know what's what anymore.. I'm just trying to keep learning!
I would use busybox sed just I'm case.
You have two choices with sed.
sed -d will remove the line and then you would echo a new one.
sed -i would replace it inline. Your current script would not work. You need to use -i flag.
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
I would use busybox sed just I'm case.
You have two choices with sed.
sed -d will remove the line and then you would echo a new one.
sed -i would replace it inline. Your current script would not work. You need to use -i flag.
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
I would actually prefer it removed the original line if it will add the modified line at the end of the build.prop
So would this work:
if grep ro.ril.gprsclass= /system/build.prop ; then
busybox sed -d 's/^ro.ril.gprsclass=*/ro.ril.gprsclass=12/g' /system/build.prop
else
busybox echo "ro.ril.gprsclass=12" >> /system/build.prop
Click to expand...
Click to collapse
Or does the sed command have to be modified because of the -d or because of the grep command?
I appreciate you taking the time- I have had several questions get totally overlooked when trying to ask development questions, no matter where I post! You're awesome(and people will be thankful when I get this done, I'm sure!)
SBD
Code:
#!/bin/bash
arg="Cool ass rom bro!"
oldarg=`grep ro.product.version /system/build.prop |cut -d"=" -f2`
sed -i "s/^ro.product.version=*/ro.product.version=${arg}/g" /system/build.prop >> /tmp/tmp-prop
chknewarg=`grep ro.product.version /tmp/tmp-prop |cut -d"=" -f2`
if "$chknewarg" = "$arg"; then
mv /tmp/tmp-prop /system/build.prop
echo "File edited"
else
rm /tmp/tmp-prop
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
POC, piece not tested, but should be what you are looking for. This will indeed sed the file but output the file to tmp, then run a check to make sure it wrote it properly, if so it will replace your file. Simple enough.
lithid-cm said:
Code:
#!/bin/bash
arg="Cool ass rom bro!"
oldarg=`grep ro.product.version /system/build.prop |cut -d"=" -f2`
sed -i "s/^ro.product.version=*/ro.product.version=${arg}/g" /system/build.prop >> /tmp/tmp-prop
chknewarg=`grep ro.product.version /tmp/tmp-prop |cut -d"=" -f2`
if "$chknewarg" = "$arg"; then
mv /tmp/tmp-prop /system/build.prop
echo "File edited"
else
rm /tmp/tmp-prop
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
POC, piece not tested, but should be what you are looking for. This will indeed sed the file but output the file to tmp, then run a check to make sure it wrote it properly, if so it will replace your file. Simple enough.
Click to expand...
Click to collapse
Okay, if I get this right, the line that says
Code:
chknewarg=`grep ro.product.version /tmp/tmp-prop |cut -d"=" -f2`
is cutting the line that was taken out or modified by sed, or added by the grep command if it didn't exist, and it puts that line at the end of the original build.prop? I could just have this same script 10 times if I wanted to make 10 prop edits and all would be at the end of the original build.prop?
I plan on making a backup of the original build.prop in the script before doing any of this, I just want to make sure that I understand exactly what the outcome is(and this is all just trying to learn anyways, so I am trying to breakdown the commands to understand which line is doing what)..
And thanks for the reply, I'm trying to keep it simple, but I also want to do this as safely as possible too if this goes right, this might end up modifying many phones, and I don't want to screw up any of them!
EDIT: and is there a way I can test this on my pc before trying it on the phone? I would think there is a way to run the script on my pc with a test build.prop to make sure it makes the expected changes- THIS would be very helpful in getting the script perfect!
test it with this:
script
Code:
#!/bin/bash
file=$HOME/build.prop
tmpf=/tmp/tmp-prop
line=ro.product.version
arg="Cool ass rom bro!"
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
mv $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
$HOME/build.prop
Code:
ro.product.version=Old Rom Name
ro.generic.type=ForSure
Btw. Do you plan on running this script from Android or from Linux?
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
Btw. Do you plan on running this script from Android or from Linux?
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
Yes, it does matter if your running from the linux OS or android. My example was more edited for him to test locally. There will need to be a few changes before he can run this via android. Plus he should think about getting his own busybox binary to run from, that way he knows that the version he has would work for him.
lithid-cm said:
Yes, it does matter if your running from the linux OS or android. My example was more edited for him to test locally. There will need to be a few changes before he can run this via android. Plus he should think about getting his own busybox binary to run from, that way he knows that the version he has would work for him.
Click to expand...
Click to collapse
Yeah I just wanted it to be clear for him. Since your sample script has /bin/bash I didn't want OP to be confused at why it didn't work
And definitely as lithid said you should build your own busybox so you know what all the applets are and what arguments they can receive.
If you need one I have one built with all features enabled. (v1.9.4) I need to download latest source.
lithid-cm said:
Yes, it does matter if your running from the linux OS or android. My example was more edited for him to test locally. There will need to be a few changes before he can run this via android. Plus he should think about getting his own busybox binary to run from, that way he knows that the version he has would work for him.
Click to expand...
Click to collapse
Well, I decided that I can try testing with script manager, the goal is to have an updater-script run this script to make a backup then the modifications to the build.prop that I need. I modified your last example to this
Code:
#!/bin/bash
file=/system/build.prop
tmpf=/tmp/tmp-prop
line=ro.product.version
arg="Cool ass rom bro!"
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
mv $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
and I get a
Code:
failed on '/tmp/tmp-prop' - cross-device link
File edited
And yes I am running it as root.
But I imagine it is because commands in the script aren't using busybox? The final update already has the busybox binary to run from that SHOULD work - but I'll gladly take an updated one!
So for testing with script manager(or even in my flashable) what changes do I need to make? I figured I'd ask before I try flashing this..
EDIT: I did some googling, the only reason it didn't work with Script manager had to do with the mv command, I changed it to copy, and it executed beautifully.. since it deletes the tmp file anyways, shouldn't be an issue right?
Edit2: This is where my noobiness with scripts come in(especially when you involve if/then or variable statements)
I am trying to create probably 15 build.prop edits, I am sure there is just an error in the formatting(or worse), but I get a
test2.sh[11]: syntax error: 'if' unmatched
Click to expand...
Click to collapse
when I try to add the next build.prop edit:
#!/bin/bash
file=/system/build.prop
tmpf=/sdcard/tmp/tmp-prop
arg="Cool ass rom bro!"
oldarg=`busybox grep ro.product.version $file |cut -d"=" -f2`
sed "s/ro.product.version=.*/ro.product.version=${arg}/g" $file > $tmpf
chknewarg=`busybox grep ro.product.version $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
arg2="12"
oldarg2=`ro.ril.gprsclass $file |cut -d"=" -f2`
sed "s/ro.ril.gprsclass=.*/ro.product.version=${arg2}/g" $file > $tmpf
chknewarg=`busybox grep ro.ril.gprsclass $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg2" ]; then
cp $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg2, got $chknewarg instead"
exit 1
fi
exit 0
Click to expand...
Click to collapse
Change #/bin/bash at the top to #/system/bin/sh
That was what my previous comment was referring to
Sent from my PG86100 using Tapatalk 2
tommytomatoe said:
Change #/bin/bash at the top to #/system/bin/sh
That was what my previous comment was referring to
Sent from my PG86100 using Tapatalk 2
Click to expand...
Click to collapse
Noted. I just realized this script doesn't create the line if the line isn't found.. how do I fix that?
For example this:
Code:
#!/sbin/sh
file=/system/build.prop
tmpf=/sdcard/tmp/tmp-prop
line=ro.ril.gprsclass
arg="12"
oldarg=`busybox grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
echo "File edited"
else
rm $tmpf
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
exit 0
Gives me "Expected 12, got instead"
so how do I make sure to insert the line if it isn't actually there? People rolling with stock won't have many of the tweaks I am trying to modify- I want to make sure they are covered(without possibly duplicating script)
Silentbtdeadly said:
Noted. I just realized this script doesn't create the line if the line isn't found.. how do I fix that?
For example this:
Gives me "Expected 12, got instead"
so how do I make sure to insert the line if it isn't actually there? People rolling with stock won't have many of the tweaks I am trying to modify- I want to make sure they are covered(without possibly duplicating script)
Click to expand...
Click to collapse
Code:
#/system/bin/sh
# Definitions
file=/system/build.prop
tmpf=/tmp/tmp-prop
line_list="ro.product.version=New ro.ril.gprsclass=12"
# Function to get args as needed for loop
getargs() {
par=$1
line=`echo $par |cut -d"=" -f1`
arg=`echo $par |cut -d"=" -f2`
}
# Loop to make all changes in line_list
for x in $line_lst; do
# Get all needed arguments
getargs $x
# Write this change to a tmp file to check on it
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
# Check if the change was made
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "File edited"
else
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
# If it doesn't exist at all append it to the file
chkexists=`grep -c $line $file`
if [ $chkexists -eq 0 ]; then
echo "$x" >> $file
fi
done
exit 0
lithid-cm said:
Code:
#/system/bin/sh
# Definitions
file=/system/build.prop
tmpf=/tmp/tmp-prop
line_list="ro.product.version=New ro.ril.gprsclass=12"
# Function to get args as needed for loop
getargs() {
par=$1
line=`echo $par |cut -d"=" -f1`
arg=`echo $par |cut -d"=" -f2`
}
# Loop to make all changes in line_list
for x in $line_lst; do
# Get all needed arguments
getargs $x
# Write this change to a tmp file to check on it
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf
# Check if the change was made
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "File edited"
else
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
# If it doesn't exist at all append it to the file
chkexists=`grep -c $line $file`
if [ $chkexists -eq 0 ]; then
echo "$x" >> $file
fi
done
exit 0
Click to expand...
Click to collapse
Alright, I got some stuff to do now so I won't be able to play with it for a while, but extra thanks for including the #reasons for the lines, with that I will hopefully be able to get it working AND learn more about what it is I am doing..
Of course the frustrating part is that as a CONCEPT this seems so simple, and I was a little scared it would get fairly complicated to do it.. but this isn't as bad as I thought it would be. Thumbs up for the help!
Alright, let me ask you this, because I haven't decided yet what the final choice will be as far as future updates..
What if I did this - my original release has lines like this in the updater script:
ui_print(" Tweaking /system/build.prop...");
set_perm(0, 0, 0777, "/system/tmp/add_to_buildprop.sh");
run_program("/system/tmp/add_to_buildprop.sh");
set_perm(0, 0, 0777, "/system/tmp/tweak1.sh");
run_program("/system/tmp/tweak1.sh");
set_perm(0, 0, 0777, "/system/tmp/tweak2.sh");
Click to expand...
Click to collapse
The add_to_buildprop.sh script could be changed to a different script(to avoid duplicates), and each tweak.sh script would modify or add ONE line of code in the build.prop.
Calling up separate scripts, each modifying the build.prop like the code in post #14(except with code added to add a line when none exists)..
Then in the next update I add NEW tweaks - this way if someone is new to the "rom" they would flash the first update, then the second one - or I could offer a combined update for new users and old alike(as long as the scripts were written to modify or add missing lines in the build.prop it wouldn't create duplicate lines, and everything they've already flashed wouldn't duplicate)?
I'm just seeing how complicated the script in the last post would get as I continue to add more and more updates to the same script, rather than create more small flashable scripts and modifying the updater script to flash them? Does this make sense?
I am guessing this is why people put out full "roms" - but I am trying to find a way to accomplish the same task for EVERYONE - as long as I pick the right modifications(like specific to the ICS build) it WILL work on ANY rom..
If my logic makes sense, then what lines would I add to the code in post #14 to add lines when they don't already exist? I'm sorry if I am being a pain, but it seems easier to flash 14 scripts than make one incredibly complex script that makes 14 changes..(especially when you consider future updates)
Thanks in advance
SBD
Silentbtdeadly said:
Alright, let me ask you this, because I haven't decided yet what the final choice will be as far as future updates..
What if I did this - my original release has lines like this in the updater script:
The add_to_buildprop.sh script could be changed to a different script(to avoid duplicates), and each tweak.sh script would modify or add ONE line of code in the build.prop.
Calling up separate scripts, each modifying the build.prop like the code in post #14(except with code added to add a line when none exists)..
Then in the next update I add NEW tweaks - this way if someone is new to the "rom" they would flash the first update, then the second one - or I could offer a combined update for new users and old alike(as long as the scripts were written to modify or add missing lines in the build.prop it wouldn't create duplicate lines, and everything they've already flashed wouldn't duplicate)?
I'm just seeing how complicated the script in the last post would get as I continue to add more and more updates to the same script, rather than create more small flashable scripts and modifying the updater script to flash them? Does this make sense?
I am guessing this is why people put out full "roms" - but I am trying to find a way to accomplish the same task for EVERYONE - as long as I pick the right modifications(like specific to the ICS build) it WILL work on ANY rom..
If my logic makes sense, then what lines would I add to the code in post #14 to add lines when they don't already exist? I'm sorry if I am being a pain, but it seems easier to flash 14 scripts than make one incredibly complex script that makes 14 changes..(especially when you consider future updates)
Thanks in advance
SBD
Click to expand...
Click to collapse
The script I gave you already does everything. Just add edits to line_list
Sent from my Nexus S 4G using xda premium
lithid-cm said:
The script I gave you already does everything. Just add edits to line_list
Sent from my Nexus S 4G using xda premium
Click to expand...
Click to collapse
Alright, I just wasn't sure if this code was better for a one time flashable since I intended to put out future updates.. I'm gonna play with it now, and thanks again for taking the time to put so much work into it!(it is quite informative, and most of this is me trying to learn, to break into the next level of work).
Thanks again!
Oh also, in the script make sure you use busybox to mount system with rw (busybox mount -o remount,rw /system). It is not enough most of the time to Mont system in updater-script
Sent from my PG86100 using Tapatalk 2
Hi Brothers, if you experience a low battery life in your phone, use this Script...
requirements:
Busybox(latest version)
Rooted phone
kernel with init.d support
Installation:
Boot to recovery mode
backup
flash the BATTERYSCRIPT.zip
done...
Reboot
Uninstall:
Boot to recovery mode
flash the UNINSTALLER.zip
reboot
How to use:
Type "save" in terminal emulator
thats it...
note: Im not responsible if anything happen to your phone... and this script is not for stockrom
Downloads:
BATTERYSCRIPT.ZIP | Mediafire
UNINSTALLER.ZIP | Mediafire
Tested Devices:
X10 mini
Hi,
Could you please tell a little more about what your script does? I prefer to know what stuff does before I flash it on my phone...
Montezuma10 said:
Hi,
Could you please tell a little more about what your script does? I prefer to know what stuff does before I flash it on my phone...
Click to expand...
Click to collapse
it saves a lot of battery life on your phone and also it kills mediaserver which is responsible for battery draining...
#!/system/bin/sh
# Battery Script
# By R3v3nGe @ xda
clear
id=`id`; id=`echo ${id#*=}`; id=`echo ${id%%\(*}`; id=`echo ${id%% *}`
if [ "$id" != "0" ] && [ "$id" != "root" ];
then
sleep 1
echo ""
echo "Not Running as Root"
echo ""
sleep 1
echo ""
echo "Please type 'su' first before typing 'save'..."
echo ""
exit
fi
echo ""
echo "Saving Phone's Battery Life"
setprop wifi.supplicant_scan_interval=120;
setprop pm.sleep_mode=1;
setprop ro.ril.disable.power.collapse=1;
echo "500" > /proc/sys/vm/dirty_expire_centisecs;
echo "1000" > /proc/sys/vm/dirty_writeback_centisecs;
echo "Killing Mediaserver(Drains A lot of Battery Life If not killed)"
killall -9 android.process.media
killall -9 mediaserver
echo "Done..."
echo "Phone's Battery Life is Saved"
echo ""
ferotakis said:
setprop wifi.supplicant_scan_interval=120;
setprop pm.sleep_mode=1;
setprop ro.ril.disable.power.collapse=1;
Click to expand...
Click to collapse
Lol. That is wrong.
neobuddy89 said:
Lol. That is wrong.
Click to expand...
Click to collapse
Not wrong, merely redundant. Those options are already set in just about every build.prop in just about every custom ROM I've seen.
Thanks, its work for my x10 mini pro, with wipe battery stats add more life about 2x times
Please Close This Thread...
Thank You!
Sent from my E10i using xda app-developers app
Hey
Does this script reduce performance?
Dear developers,
I have an issue in my script switching from Android 9 to 10 (devices from a Umidigi s3 Pro to a Umidigi F2)
I have installed Bosybox App on the first and Busybox Magisk module on the latter
Now the script does not work because the command
list=(`busybox find "$dirs" -type f -name *.$ext`)
returns an empty array
This is the complete script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <[email protected]> v1.4 01.01.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
# here we have the ISSUE
list=(`busybox find "$dirs" -type f -name *.$ext`)
# count number of files
num=${#list[@]}
# initialize random generator
RANDOM=$$
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[ran]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext$delim2
Can you please help me why this happens, and how to fix it?
Thank you very much for your attention!
Uranya said:
[...]
Click to expand...
Click to collapse
Having done some tests I have found this:
opening a root privileged terminal and executing
---
echo `find /storage/7BC3-1805/Music/MP3/Abba -type f -name *.mp3`
---
it returns two strings containing the names of files inside that folder, but putting it in my script continues to return an empty array, so the issue is not in the access to the folder, but in the syntax, I guess
try putting that *.$ext into quotes...
Dear friends, CXZa, after a couple of hours debugging the script, finally, I have found the mistake!
The line to be used is:
list=( `find "$dirs" -type f -name "*.$ext"` )
it is a very subtle difference: the space after and before the parenthesis!
(even the word busybox is useless)
Oddly in the Busybox app (I have had on my S3 Pro) the spaces are not mandatory, whilst in the Busybox Magisk module those spaces ARE mandatory!
I'm using that script for almost 8 years to have an every day different music for my wake up.
I'm using Tasker to call it just before my alarm get off, so the same file contains every day, a different song.
I have done a change also in the array index that did not began by 0...
So, here it is the right script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <@uranya7x> v1.5 26.03.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
list=( `find "$dirs" -type f -name "*.$ext"` )
# count number of files
num=${#list[@]}
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[$ran-1]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext
I hope it will be useful to someone else that loves to be waked up by music...
Peace everywhere!