[Samsung Galaxy SL i9003] shaktishekhar:
Take this and try.. new link https://db.tt/D6LEO2W3 or use https://docs.google.com/file/d/0BxkICngE3Bzebm8xaTVDNkVUejA/edit?usp=drivesdk

#!/system/bin/sh
#
rm -r /data/local/tmp/*
rm -r /dev/log/*
rm -r /data/system/usagestats/*
rm -r /data/system/dropbox/*
rm -r /data/tombstones/*
rm -r /data/anr/*
busybox chmod 000 /data/system/usagestats/
busybox chmod 000 /data/system/dropbox/
busybox chmod 000 /data/anr/
busybox chmod 000 /dev/log/
busybox chmod 000 /data/tombstones/
#
fstrim -v /data
fstrim -v /cache
#
echo 8 > /sys/class/backlight/omap_bl/brightness

#!/system/bin/sh

#-------------------------------------------
# presented by Turbo Boost Team
# delta-roh & Harbir
#-------------------------------------------
# swap file in any partition
# supports /cache /data /system
#
# **** script
# ** idea from and
# ** **** developed by
# *** ** **
# * ** ** ** delta-roh
# ** ** ** ****
# ** ** ** in 2013
# ** ** ****
# **** **
# **
#-------------------------------------------
# Use file in a partition as swap space
#
# description:
# - this script creates a file in the
# configured partition as swap space
#
# installation:
# - change the parameters in the first
# section to your needs;
# swapfile size in MB
# (if size is changed, the swapfile
# will be recreated automatically)
# - copy this script to /etc/init.d
# - change the owner/group of the
# script:
# (chown root.shell 98swap_cache_vX)
# - change the access rights of the
# script:
# (chmod 755 98swap_cache_vX)
# - reboot your device
# - now check the log file
#
# uninstall:
# - change access rights of the
# script or delete it:
# (chmod 644 98swap_cache_vX)
# - stop swaping or just reboot
# (swapoff /cache/swap/swap.img)
# - delete swapfile, e.g:
# (rm /cache/swap/swap.img)
#
# version history:
# changed by ver comment
# 2013-02-02 delta-roh 1.00 release
# 2013-02-14 delta-roh 1.01 changes:
# changed some comments
# 2013-02-24 delta-roh 2.00 changes:
# script restructured
# new var for partition
# new var for min. free
# new var for min. swap
# compatibility fix:
# (e.g.Incredible)
# -correct partition rights
# -commands without path
# auto-correction of size
# (correct to avail.-min.free)
# auto check min.free mem.
# (recreate if necessary)
# auto check min. swap size
# (only create if larger)
# log file now in /data
# 2013-03-16 delta-roh 2.80 changes:
# compatibility fix:
# (e.g. Vivid)
# -available_size (Byte)
# on data exceeds 32Bit
# corrected to MByte
# current_size also to MB
# 2013-03-16 delta-roh 3.05 changes:
# allow /system
# check partition r/w
# remount if necessary
# 2013-07-09 delta-roh 3.06 changes:
# grep -> busybox grep
#
version_swap_cache="V3.00"
#----------------------------------------

#----------------------------------------
# please change/adjust these params
#----------------------------------------
# partition /cache or /data or /system
partition="/data";

# the requested swap file size in MB
swap_file_size_mb=75;

# min. free memory; below that
# value of free memory, the
# swap file will be resized -
# very nice for data partition,
# where 150MB min. is required
min_free_space_mb=150;

# minimum size of the swap file
# if size is lower, the swap will
# not be created
min_swap_size_mb=20;

# may be changed but not necessary
sub_dir="swap";
log_file_name="swap_${partition:1}.log";
log_file_path="/data/swap";
swap_file_name="swap.img";
swappiness=100;

# global variables - do not change
delete_flag=0;
exit_flag=0;
available_blocks=0;
block_size=0;
available_size_mb=0;
current_size_mb=0;
swap_file="";

#----------------------------------------
# start of the script
#----------------------------------------

# log file handling
log_file=$log_file_path/$log_file_name;
mkdir -p $log_file_path;
if [ -e $log_file ] ; then rm $log_file; fi;

echo "-------------------------------------" > $log_file;
echo "- Presented by Turbo Boost Team -" >> $log_file;
echo "- (delta-roh & Harbir) -" >> $log_file;
echo "- swapfile on any partition $version_swap_cache -" >> $log_file;
echo "- script idea from & developed by delta-roh-" >> $log_file;
echo "- (copyright 2013) -" >> $log_file;
echo "-------------------------------------" >> $log_file;

echo ">partition info:" >> $log_file;
echo " partition:\t"$partition >> $log_file;
available_blocks=`stat -t -f $partition | awk '{ print $7 }'`;
block_size=`stat -t -f $partition | awk '{ print $5 }'`;
available_size_mb=$((($available_blocks*($block_size/1024))/1024));
echo " free blocks:\t"$available_blocks" blocks" >> $log_file;
echo " block size:\t"$block_size" Byte" >> $log_file;
echo " free space:\t"$available_size_mb" MB" >> $log_file;

# check if partition is allowed
if [ $partition = "/cache" -o $partition = "/data" -o $partition = "/system" ] ;
then
# partition is allowed - check mount state
# (this is quite tricky due to different
# formats of the mount command)
echo ">partition $partition is allowed" >> $log_file;
echo ">check mount state (rw or ro)" >> $log_file;
mount_state=`mount | busybox grep -e " $partition " | busybox grep -o -e "rw," -e "ro,"`;
if [ $mount_state = "ro," -o $mount_state = "rw," ] ;
then
if [ $mount_state = "ro," ] ;
then
echo " partition is read-only" >> $log_file;
echo " remount necessary - try ..." >> $log_file;
mount -o remount,rw $partition >> $log_file;
echo " checking remount ..." >> $log_file;
mount_state=`mount | busybox grep -e " $partition " | busybox grep -o -e "rw," -e "ro,"`;
if [ $mount_state = "rw," ] ;
then
echo " remount was successful!" >> $log_file;
echo " partition is read-write" >> $log_file;
else
echo "Error: remount failed!" >> $log_file;

exit_flag=1;
fi;
else
echo " partition is read-write" >> $log_file;
fi;
else
echo "Error: cannot get" >> $log_file;
echo "\t\tstate of $partition!" >> $log_file;

exit_flag=1;
fi;
else
echo "Error: $partition not allowed!" >> $log_file;
echo "\tpartition has to be:" >> $log_file;
echo "\t/cache or /data or /system" >> $log_file;

exit_flag=1;
fi;

# prepare partition
if [ $exit_flag -eq 0 ] ;
then
echo " change access rights of $partition" >> $log_file;
chmod 775 $partition;
echo " create directory for swap file" >> $log_file;
mkdir -p $partition/$sub_dir;
chmod 775 $partition/$sub_dir;

# output of script parameters
echo ">other parameters:" >> $log_file;
echo " sub directory:\t"$sub_dir >> $log_file;
swap_file=$partition/$sub_dir/$swap_file_name;
echo " swap file:\t"$swap_file >> $log_file;
echo " log file:\t"$log_file >> $log_file;
echo " swap size:\t"$swap_file_size_mb" MB" >> $log_file;
echo " min. free:\t"$min_free_space_mb" MB" >> $log_file;
echo " min. swap:\t"$min_swap_size_mb" MB" >> $log_file;
echo " swappiness:\t"$swappiness >> $log_file;
fi;

# check actual swap file and delete if necessary
delete_flag=0;
if [ -e $swap_file -a $exit_flag -eq 0 ] ;
then
current_size_mb=$(((`stat -t $swap_file | awk '{ print $2 }'`)/1024/1024));
echo " current swap:\t"$current_size_mb" MB" >> $log_file;
echo "---------swapfile exists-------------" >> $log_file;
echo ">check free memory limit" >> $log_file;
if [ $min_free_space_mb -gt $available_size_mb ] ;
then
echo " min. free memory too low" >> $log_file;
delete_flag=1;
else
echo " min. free memory ok" >> $log_file;
# free space is more or equal to the limit

if [ $current_size_mb -gt $swap_file_size_mb ] ;
then
# swap file is greater than configured
echo " swap file requested smaller" >> $log_file;
delete_flag=1
fi;

if [ $current_size_mb -lt $swap_file_size_mb ] ;
then
# swap file is smaller than configured - should be larger
echo " swap file requested larger" >> $log_file;
if [ $min_free_space_mb -lt $available_size_mb ] ;
then
# min. free space not reached yet - delete, resize
echo " min. free space not reached" >> $log_file;
echo " delete and resize swap" >> $log_file;
delete_flag=1;
else
echo " min. free space reached" >> $log_file;
fi;
fi;
fi;
fi;

# delete swap file if needed
if [ $delete_flag -eq 1 -a $exit_flag -eq 0 ] ;
then
echo ">delete current swap file" >> $log_file;
rm $swap_file >> $log_file;
if [ ! -e $swap_file ] ; then current_size_mb=0; fi;
echo " reinitialize free space:" >> $log_file;
available_blocks=`stat -t -f $partition | awk '{ print $7 }'`;
block_size=`stat -t -f $partition | awk '{ print $5 }'`;
available_size_mb=$((($available_blocks*($block_size/1024))/1024));
echo " free blocks:\t"$available_blocks" blocks" >> $log_file;
echo " block size:\t"$block_size" Byte" >> $log_file;
echo " free space:\t"$available_size_mb" MB" >> $log_file;
echo " current swap:\t"$current_size_mb" MB" >> $log_file;
fi;

# create new swap file if necessary
if [ ! -e $swap_file -a $exit_flag -eq 0 ] ;
then
echo "-------swapfile does not exist-------" >> $log_file;
echo ">check requested size of swapfile" >> $log_file;
if [ $swap_file_size_mb -le $(($available_size_mb-$min_free_space_mb)) ] ;
then
echo " requested size OK" >> $log_file;
else
echo " requested size too large" >> $log_file;
echo " autocorrect size" >> $log_file;
swap_file_size_mb=$(($available_size_mb-$min_free_space_mb));
echo " corrected size:\t"$swap_file_size_mb" MB" >> $log_file;
fi;
if [ $swap_file_size_mb -ge $min_swap_size_mb ] ;
then
echo " create swapfile" >> $log_file;
dd if=/dev/zero of=$swap_file bs=1048576 count=$swap_file_size_mb >> $log_file;
else
echo " swapfile lower than min." >> $log_file;
fi;
else
echo " actual swapfile matches" >> $log_file;
fi;

# initialize swap file
if [ -e $swap_file -a $exit_flag -eq 0 ] ;
then
echo ">initialize swapfile" >> $log_file;
echo " create swapfile structure in file" >> $log_file;
# uid 0=root / gid 1000=system
chown 0.1000 $swap_file >> $log_file;
chmod 666 $swap_file >> $log_file;
mkswap $swap_file >> $log_file;

echo " activate swapfile" >> $log_file;
swapon $swap_file >> $log_file;

echo " set swappiness=($swappiness)" >> $log_file;
# chmod 666 /proc/sys/vm/swappiness >> $log_file;
echo $swappiness > /proc/sys/vm/swappiness;

echo "--write infos about swapfile to log--" >> $log_file;
echo ">result of cat /proc/swaps:" >> $log_file;
cat /proc/swaps >> $log_file;
echo "" >> $log_file;

# echo ">result of cat /proc/meminfo:" >> $log_file;
# cat /proc/meminfo >> $log_file;
# echo "" >> $log_file;

echo ">result of free:" >> $log_file;
free >> $log_file;

echo "Exit with success!" >> $log_file;
echo "---end of swap to cache partition----" >> $log_file;
echo "" >> $log_file;
else
echo "ERROR: creation of swapfile failed! -" >> $log_file;

exit_flag=1;
fi;

# check for errors
if [ $exit_flag -eq 0 ] ;
then
# all actions succeeded
exit 0;
else
# an error occured - write some infos
echo "--write some infos to log--" >> $log_file;
echo ">result of ls -l "$partition":" >> $log_file;
ls -l $partition >> $log_file;

echo "" >> $log_file;
echo ">result of ls -l "$partition"/"$sub_dir":" >> $log_file;
ls -l $partition/$sub_dir >> $log_file;

echo ">result of df:" >> $log_file;
df "/system" "/data" "/cache" >> $log_file;

echo ">result of du -c -k $partition:" >> $log_file;
du -c -k $partition >> $log_file;

echo "Exit with error!" >> $log_file;
echo "---end of swap to cache partition----" >> $log_file;
echo "" >> $log_file;

exit 1;
fi;

#-------------------------------------------
# EOF
#-------------------------------------------

#!/system/bin/sh

#-------------------------------------------
# presented by Turbo Boost Team
# delta-roh & Harbir
#-------------------------------------------
# swap file in any partition
# supports /cache /data /system
#
# **** script
# ** idea from and
# ** **** developed by
# *** ** **
# * ** ** ** delta-roh
# ** ** ** ****
# ** ** ** in 2013
# ** ** ****
# **** **
# **
#-------------------------------------------
# Use file in a partition as swap space
#
# description:
# - this script creates a file in the
# configured partition as swap space
#
# installation:
# - change the parameters in the first
# section to your needs;
# swapfile size in MB
# (if size is changed, the swapfile
# will be recreated automatically)
# - copy this script to /etc/init.d
# - change the owner/group of the
# script:
# (chown root.shell 98swap_cache_vX)
# - change the access rights of the
# script:
# (chmod 755 98swap_cache_vX)
# - reboot your device
# - now check the log file
#
# uninstall:
# - change access rights of the
# script or delete it:
# (chmod 644 98swap_cache_vX)
# - stop swaping or just reboot
# (swapoff /cache/swap/swap.img)
# - delete swapfile, e.g:
# (rm /cache/swap/swap.img)
#
# version history:
# changed by ver comment
# 2013-02-02 delta-roh 1.00 release
# 2013-02-14 delta-roh 1.01 changes:
# changed some comments
# 2013-02-24 delta-roh 2.00 changes:
# script restructured
# new var for partition
# new var for min. free
# new var for min. swap
# compatibility fix:
# (e.g.Incredible)
# -correct partition rights
# -commands without path
# auto-correction of size
# (correct to avail.-min.free)
# auto check min.free mem.
# (recreate if necessary)
# auto check min. swap size
# (only create if larger)
# log file now in /data
# 2013-03-16 delta-roh 2.80 changes:
# compatibility fix:
# (e.g. Vivid)
# -available_size (Byte)
# on data exceeds 32Bit
# corrected to MByte
# current_size also to MB
# 2013-03-16 delta-roh 3.05 changes:
# allow /system
# check partition r/w
# remount if necessary
# 2013-07-09 delta-roh 3.06 changes:
# grep -> busybox grep
#
version_swap_cache="V3.00"
#----------------------------------------

#----------------------------------------
# please change/adjust these params
#----------------------------------------
# partition /cache or /data or /system
partition="/cache";

# the requested swap file size in MB
swap_file_size_mb=75;

# min. free memory; below that
# value of free memory, the
# swap file will be resized -
# very nice for data partition,
# where 150MB min. is required
min_free_space_mb=2;

# minimum size of the swap file
# if size is lower, the swap will
# not be created
min_swap_size_mb=20;

# may be changed but not necessary
sub_dir="swap";
log_file_name="swap_${partition:1}.log";
log_file_path="/data/swap";
swap_file_name="swap.img";
swappiness=100;

# global variables - do not change
delete_flag=0;
exit_flag=0;
available_blocks=0;
block_size=0;
available_size_mb=0;
current_size_mb=0;
swap_file="";

#----------------------------------------
# start of the script
#----------------------------------------

# log file handling
log_file=$log_file_path/$log_file_name;
mkdir -p $log_file_path;
if [ -e $log_file ] ; then rm $log_file; fi;

echo "-------------------------------------" > $log_file;
echo "- Presented by Turbo Boost Team -" >> $log_file;
echo "- (delta-roh & Harbir) -" >> $log_file;
echo "- swapfile on any partition $version_swap_cache -" >> $log_file;
echo "- script idea from & developed by delta-roh-" >> $log_file;
echo "- (copyright 2013) -" >> $log_file;
echo "-------------------------------------" >> $log_file;

echo ">partition info:" >> $log_file;
echo " partition:\t"$partition >> $log_file;
available_blocks=`stat -t -f $partition | awk '{ print $7 }'`;
block_size=`stat -t -f $partition | awk '{ print $5 }'`;
available_size_mb=$((($available_blocks*($block_size/1024))/1024));
echo " free blocks:\t"$available_blocks" blocks" >> $log_file;
echo " block size:\t"$block_size" Byte" >> $log_file;
echo " free space:\t"$available_size_mb" MB" >> $log_file;

# check if partition is allowed
if [ $partition = "/cache" -o $partition = "/data" -o $partition = "/system" ] ;
then
# partition is allowed - check mount state
# (this is quite tricky due to different
# formats of the mount command)
echo ">partition $partition is allowed" >> $log_file;
echo ">check mount state (rw or ro)" >> $log_file;
mount_state=`mount | busybox grep -e " $partition " | busybox grep -o -e "rw," -e "ro,"`;
if [ $mount_state = "ro," -o $mount_state = "rw," ] ;
then
if [ $mount_state = "ro," ] ;
then
echo " partition is read-only" >> $log_file;
echo " remount necessary - try ..." >> $log_file;
mount -o remount,rw $partition >> $log_file;
echo " checking remount ..." >> $log_file;
mount_state=`mount | busybox grep -e " $partition " | busybox grep -o -e "rw," -e "ro,"`;
if [ $mount_state = "rw," ] ;
then
echo " remount was successful!" >> $log_file;
echo " partition is read-write" >> $log_file;
else
echo "Error: remount failed!" >> $log_file;

exit_flag=1;
fi;
else
echo " partition is read-write" >> $log_file;
fi;
else
echo "Error: cannot get" >> $log_file;
echo "\t\tstate of $partition!" >> $log_file;

exit_flag=1;
fi;
else
echo "Error: $partition not allowed!" >> $log_file;
echo "\tpartition has to be:" >> $log_file;
echo "\t/cache or /data or /system" >> $log_file;

exit_flag=1;
fi;

# prepare partition
if [ $exit_flag -eq 0 ] ;
then
echo " change access rights of $partition" >> $log_file;
chmod 775 $partition;
echo " create directory for swap file" >> $log_file;
mkdir -p $partition/$sub_dir;
chmod 775 $partition/$sub_dir;

# output of script parameters
echo ">other parameters:" >> $log_file;
echo " sub directory:\t"$sub_dir >> $log_file;
swap_file=$partition/$sub_dir/$swap_file_name;
echo " swap file:\t"$swap_file >> $log_file;
echo " log file:\t"$log_file >> $log_file;
echo " swap size:\t"$swap_file_size_mb" MB" >> $log_file;
echo " min. free:\t"$min_free_space_mb" MB" >> $log_file;
echo " min. swap:\t"$min_swap_size_mb" MB" >> $log_file;
echo " swappiness:\t"$swappiness >> $log_file;
fi;

# check actual swap file and delete if necessary
delete_flag=0;
if [ -e $swap_file -a $exit_flag -eq 0 ] ;
then
current_size_mb=$(((`stat -t $swap_file | awk '{ print $2 }'`)/1024/1024));
echo " current swap:\t"$current_size_mb" MB" >> $log_file;
echo "---------swapfile exists-------------" >> $log_file;
echo ">check free memory limit" >> $log_file;
if [ $min_free_space_mb -gt $available_size_mb ] ;
then
echo " min. free memory too low" >> $log_file;
delete_flag=1;
else
echo " min. free memory ok" >> $log_file;
# free space is more or equal to the limit

if [ $current_size_mb -gt $swap_file_size_mb ] ;
then
# swap file is greater than configured
echo " swap file requested smaller" >> $log_file;
delete_flag=1
fi;

if [ $current_size_mb -lt $swap_file_size_mb ] ;
then
# swap file is smaller than configured - should be larger
echo " swap file requested larger" >> $log_file;
if [ $min_free_space_mb -lt $available_size_mb ] ;
then
# min. free space not reached yet - delete, resize
echo " min. free space not reached" >> $log_file;
echo " delete and resize swap" >> $log_file;
delete_flag=1;
else
echo " min. free space reached" >> $log_file;
fi;
fi;
fi;
fi;

# delete swap file if needed
if [ $delete_flag -eq 1 -a $exit_flag -eq 0 ] ;
then
echo ">delete current swap file" >> $log_file;
rm $swap_file >> $log_file;
if [ ! -e $swap_file ] ; then current_size_mb=0; fi;
echo " reinitialize free space:" >> $log_file;
available_blocks=`stat -t -f $partition | awk '{ print $7 }'`;
block_size=`stat -t -f $partition | awk '{ print $5 }'`;
available_size_mb=$((($available_blocks*($block_size/1024))/1024));
echo " free blocks:\t"$available_blocks" blocks" >> $log_file;
echo " block size:\t"$block_size" Byte" >> $log_file;
echo " free space:\t"$available_size_mb" MB" >> $log_file;
echo " current swap:\t"$current_size_mb" MB" >> $log_file;
fi;

# create new swap file if necessary
if [ ! -e $swap_file -a $exit_flag -eq 0 ] ;
then
echo "-------swapfile does not exist-------" >> $log_file;
echo ">check requested size of swapfile" >> $log_file;
if [ $swap_file_size_mb -le $(($available_size_mb-$min_free_space_mb)) ] ;
then
echo " requested size OK" >> $log_file;
else
echo " requested size too large" >> $log_file;
echo " autocorrect size" >> $log_file;
swap_file_size_mb=$(($available_size_mb-$min_free_space_mb));
echo " corrected size:\t"$swap_file_size_mb" MB" >> $log_file;
fi;
if [ $swap_file_size_mb -ge $min_swap_size_mb ] ;
then
echo " create swapfile" >> $log_file;
dd if=/dev/zero of=$swap_file bs=1048576 count=$swap_file_size_mb >> $log_file;
else
echo " swapfile lower than min." >> $log_file;
fi;
else
echo " actual swapfile matches" >> $log_file;
fi;

# initialize swap file
if [ -e $swap_file -a $exit_flag -eq 0 ] ;
then
echo ">initialize swapfile" >> $log_file;
echo " create swapfile structure in file" >> $log_file;
# uid 0=root / gid 1000=system
chown 0.1000 $swap_file >> $log_file;
chmod 666 $swap_file >> $log_file;
mkswap $swap_file >> $log_file;

echo " activate swapfile" >> $log_file;
swapon $swap_file >> $log_file;

echo " set swappiness=($swappiness)" >> $log_file;
# chmod 666 /proc/sys/vm/swappiness >> $log_file;
echo $swappiness > /proc/sys/vm/swappiness;

echo "--write infos about swapfile to log--" >> $log_file;
echo ">result of cat /proc/swaps:" >> $log_file;
cat /proc/swaps >> $log_file;
echo "" >> $log_file;

# echo ">result of cat /proc/meminfo:" >> $log_file;
# cat /proc/meminfo >> $log_file;
# echo "" >> $log_file;

echo ">result of free:" >> $log_file;
free >> $log_file;

echo "Exit with success!" >> $log_file;
echo "---end of swap to cache partition----" >> $log_file;
echo "" >> $log_file;
else
echo "ERROR: creation of swapfile failed! -" >> $log_file;

exit_flag=1;
fi;

# check for errors
if [ $exit_flag -eq 0 ] ;
then
# all actions succeeded
exit 0;
else
# an error occured - write some infos
echo "--write some infos to log--" >> $log_file;
echo ">result of ls -l "$partition":" >> $log_file;
ls -l $partition >> $log_file;

echo "" >> $log_file;
echo ">result of ls -l "$partition"/"$sub_dir":" >> $log_file;
ls -l $partition/$sub_dir >> $log_file;

echo ">result of df:" >> $log_file;
df "/system" "/data" "/cache" >> $log_file;

echo ">result of du -c -k $partition:" >> $log_file;
du -c -k $partition >> $log_file;

echo "Exit with error!" >> $log_file;
echo "---end of swap to cache partition----" >> $log_file;
echo "" >> $log_file;

exit 1;
fi;

#-------------------------------------------
# EOF
#-------------------------------------------

#!/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)
#

# 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
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;
fi;

#!/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)

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
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;
fi