#!/system/bin/sh

#
# SQLite Vacuuming
#
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;

busybox mount -o rw,remount /system
# SYMLINK ALL OF THEM BUSYBOX APPLETS THERE INTO YURR XBIN WHEEEEEEEEEEE
#
# for M in `busybox --help | busybox grep 'Currently defined functions:' -A30 | busybox grep -v 'Currently defined functions:'|busybox tr , '\n'|busybox tr -d '\n\t'|busybox tr ' ' '\n'`; do ln -s busybox /system/xbin/$M; done



# Nuking run once scripts
#
rm /system/etc/init.d/01self-destruct


busybox mount -o ro,remount /system
