[G1 Android Development] :
will try that. yea, i have one. use it for compcache/swap. i'll try it and see what happens. i really hope it does. i <3ed jit when i had it.

edit: still no blue led. :/ also broke my compcache/swap settings. does this have anything to do with user.conf as well?

my userinit.sh: (just pay attention to top - bottom is same ol same ol blah blah)

edit again: removed everything but what was in original txt file and still no blue led. :/

#!/system/bin/sh
#
# dalvik-cache fix by Phonekenstein
# URI: www.androidonroids.com
#
# version: 1.1
#
for dc in dalvik-cache;
do
umount /cache/$dc;
rm -fr /cache/$dc;
mkdir /cache/$dc;
chown 1000:1000 /cache/$dc;
chmod 771 /cache/$dc;
mount -o bind /data/$dc /cache/$dc;
echo 255 >/sys/class/leds/blue/brightness;
done;

#!/system/bin/sh
#
CONF_FILE="/system/sd/user.conf";
WHICHROM="CYAN42x"
apps2sd=0
media2sd=1
odex_all=0;
odex_apk=0;
app_dirs="/system/app /system/app-private /data/app /data/app-private";

compcache_en=0
cc_disksize=24
cc_memlimit=24
cc_backingswap_en=0
cc_backingswap=/dev/block/mmcblk0p3
swappiness=30
CC_DEVICE=/dev/block/ramzswap0

linux_swap_en=0
linux_swap_partition=/dev/block/mmcblk0p3
swappiness=30

sys_vm_en=0
page_cluster=3
laptop_mode=0
dirty_expire_centisecs=3000
dirty_writeback_centisecs=500
dirty_background_ratio=5
dirty_ratio=10

proc_cpu_en=0
scaling_min_freq=245760
scaling_max_freq=528000
sampling_rate=2000000
powersave_bias=0
up_threshold=40

CC_NEW_DECT=0;

swap_file_en=0;
linux_swap_file_size=32;
linux_swap_file=/sdcard/swap.file;
insmod="/system/xbin/bb/insmod"
rmmod="/system/xbin/bb/rmmod"
modprobe="/system/xbin/bb/modprobe"

usage() {
echo
echo "Usage:"
echo "/system/sd/userinit.sh [-s|-c config.file|-i]"
echo
echo "Default:"
echo "Sets system configuration based on the paratermers"
echo "that listed in /system/sd/user.conf"
echo
echo " -s: check configuration status and cross"
echo " verifiction with user configurations "
echo " -c config.file: use user parameters that defined"
echo " in config.file "
echo " -i: Current system settings and info "
echo
echo
exit 0
}

symbolic_link()
{

if [ -e /system/sd/userinit.sh ] && [ ! -h /system/bin/userinit ];
then
MOUNT_CHK;
busybox rm /system/bin/userinit
busybox ln -s /system/sd/userinit.sh /system/bin/userinit;
fi;
}

parse_args()
{
STATUS_CHK=0;
DISP_SYS_INFO=0;
while [ $# != 0 ]; do
case $1 in
-s) STATUS_CHK=1;shift;
;;
-c) CONF_FILE=$2; shift;shift;
;;
-i) DISP_SYS_INFO=1; shift;
;;
-*)	usage;
;;
*)	usage;
;;
esac;

done;

if [ ! -e ${CONF_FILE} ]; then
usage;
fi

}

# reads user specfic parameters
GET_USER_CONF() {
MATCH=0;
if [ -e ${CONF_FILE} ]; then
while read inputline;
do
# skip comments
COMMENTS=$(echo $inputline | grep "#" | wc -l);
COMMENT2=$(echo $inputline | grep "#" | awk -F"#" '{print $1}');
[[ $COMMENTS -eq 1 ]] && [[ -z "$COMMENT2" ]] && continue

# skip empty lines
[[ -z "$inputline" ]] && continue

inputline=$(echo $inputline | awk -F"#" '{print $1}');

# check begin of configurations
BEGIN_CHK=$(echo $inputline | grep "{" | wc -l);
END_CHK=$(echo $inputline | grep "}" | wc -l);

if [ $MATCH -eq 0 ]; then
if [ ${BEGIN_CHK} -eq 1 ] ; then
MATCH=1;
GROUP=$(echo $inputline | grep "{" | awk -F"{" '{print $1}');
GROUP_PARS="${GROUP}_pars=\""
eval "$GROUP=1"
fi;
else
if [ ${END_CHK} -eq 1 ]; then
MATCH=0;
if [ $GROUP != "custom_shells" ]; then
GROUP_PARS="$GROUP_PARS\""
eval $GROUP_PARS
fi
else
if [ $GROUP == "custom_shells" ]; then
#inputline=$(echo $inputline | sed -e 's/;//g');
#inputline=$(echo $inputline | sed -e 's/"/\"/g');
custom_shells_pars="$custom_shells_pars #"$inputline" "
else
eval $inputline
PAR=$(echo $inputline | awk -F"=" '{print $1}');
if [ $(echo $inputline | grep _en | wc -l) -eq 0 ]; then
GROUP_PARS="$GROUP_PARS $inputline "
fi;
fi;
fi;
fi;
done < $CONF_FILE ;
fi;

LAST_LINE_CHK=`tail -1 $CONF_FILE | grep "}" | wc -l`
if [ ${LAST_LINE_CHK} -eq 1 ] && [ $MATCH -eq 1 ]; then
MATCH=0;
GROUP_PARS="$GROUP_PARS\""
eval $GROUP_PARS
fi

# checking compcache version
if [ -e /system/bin/rzscontrol ]; then
CC_NEW_DECT=1;
CC_STATUS_FLAG="rzscontrol ${CC_DEVICE} -s";
CC_VERSION="0.6+"
else
CC_NEW_DECT=0;
CC_STATUS_FLAG="cat /proc/ramzswap";
CC_VERSION="0.5"
fi;

# overwrite swapiness
if [ ${compcache_en} -eq 1 ] ; then
swappiness=${cc_swappiness};
fi;
}

USER_CONF_CHECK()
{
if [ ${STATUS_CHK} -eq 1 ] || [ ${DISP_SYS_INFO} -eq 1 ]; then
echo === user.conf ===
#echo general_pars=$general_pars
echo "*** general ***"
#echo general=$general
echo apps2sd=$apps2sd
echo media2sd=$media2sd
echo
#echo compcache_pars=$compcache_pars
echo "*** CompCache ***"
#echo compcache=$compcache
echo compcache_en=$compcache_en
echo cc_memlimit=$cc_memlimit
echo cc_disksize=$cc_disksize
echo cc_backingswap_en=$cc_backingswap_en
echo cc_backingswap=$cc_backingswap
echo swappiness=$swappiness
echo
echo "*** Swap File ***"
echo swap_file_en=$swap_file_en
echo linux_swap_file_size=$linux_swap_file_size
echo linux_swap_file=$linux_swap_file
echo
echo "*** Linux Swap ***"
#echo linux_swap_pars=$linux_swap_pars
#echo linux_swap=$linux_swap
echo linux_swap_en=$linux_swap_en
echo linux_swap_partition=$linux_swap_partition
echo
echo "*** VM ***"
#echo sys_vm_pars=$sys_vm_pars
#echo sys_vm=$sys_vm
echo sys_vm_en=$sys_vm_en
echo page_cluster=$page_cluster
echo laptop_mode=$laptop_mode
echo dirty_expire_centisecs=$dirty_expire_centisecs
echo dirty_writeback_centisecs=$dirty_writeback_centisecs
echo dirty_background_ratio=$dirty_background_ratio
echo dirty_ratio=$dirty_ratio
echo
echo "*** CPU ***"
#echo proc_cpu_pars=$proc_cpu_pars
#echo proc_cpu=$proc_cpu
echo proc_cpu_en=$proc_cpu_en
echo scaling_min_freq=$scaling_min_freq
echo scaling_max_freq=$scaling_max_freq
echo sampling_rate=$sampling_rate
echo powersave_bias=$powersave_bias
echo up_threshold=$up_threshold
fi;

}
# check for kernel module directory
CHK_KERNEL_MOD_DIR()
{
uname_r=`uname -r`;
MODDIR=`find /system/modules -type d -name $uname_r`;
if [ ! -e $MODDIR/compcache/ramzswap.ko ]; then
echo $MODDIR/compcache/ramzswap.ko not found
MODDIR="/system/sd";
echo use $MODDIR/compcache/ramzswap.ko instead
if [ ! -e $MODDIR/compcache/ramzswap.ko ]; then
echo $MODDIR/compcache/ramzswap.ko not found
echo "ERROR!!! unable to find compcache modules."
exit 1;
fi;
fi;
}

# media to sd
MEDIA2SD()
{
if [ ${STATUS_CHK} -eq 0 ] && [ -d /system/media ] && [ ! -h /system/media ] && [ -e /system/sd/media ] && [ $media2sd -eq 1 ];
then
# fix the permissions
busybox chmod 777 /system/sd/media
for i in `ls -R /system/sd/media | grep ":" | sed "s/://"`;
do
cd $i;
busybox chmod 777 $i;
for j in `ls $i`;
do
busybox chmod 666 $j;
done
done

busybox mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
busybox rm -rf /system/media;
busybox ln -s /system/sd/media /system/media;
busybox mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system
fi;
}

CC_SWAPOFF()
{
CC_ON=$(lsmod | grep ramzswap | wc -l);
if [ $STATUS_CHK -eq 0 ] && [ ${CC_ON} -ge 1 ];
then
swapoff ${CC_DEVICE};
rm -fr ${CC_DEVICE};
#$rmmod xvmalloc;
$rmmod ramzswap;
CC_ON=$(lsmod | grep ramzswap | wc -l);
if [ ${CC_ON} -ge 1 ]; then
echo unable to remove compcache modules
fi;
fi;

}

# compcache setup
COMPCACHE()
{
if [ $STATUS_CHK -eq 1 ] && [ ${compcache_en} -eq 1 ]; then
echo
echo === CompCache status ===
echo CompCache version ${CC_VERSION}
SYS_VAL=`$CC_STATUS_FLAG | grep DiskSize | awk -F" " '{print $2}'`
CC_ON=$(lsmod | grep ramzswap | wc -l);

if [ ! -z $SYS_VAL ] && [ -e ${CC_DEVICE} ] && [ ${CC_ON} -ge 1 ]; then
echo Compcache enabled
else
echo !!!ERROR Compcache disabled
dmesg | grep ramzswap | tail -10
fi;

for i in $compcache_pars;
do
USER_VAL=$(echo $i | awk -F"=" '{print $2}');
USER_PAR=$(echo $i | awk -F"=" '{print $1}');
if [ $USER_PAR == "cc_swappiness" ]; then
SYS_VAL=`cat /proc/sys/vm/swappiness`
if [ $USER_VAL -ne "$SYS_VAL" ] || [ -z $SYS_VAL ]; then
echo !!! Unable to set compcache $USER_PAR to user specific \"$USER_VAL\"
echo Current system value is \"$SYS_VAL\"
else
echo "CompCache: $USER_PAR - "$SYS_VAL"(system) "$USER_VAL"(user)"
fi;
elif [ $USER_PAR == "cc_disksize" ] && [ ${cc_backingswap_en} -eq 0 ] ; then
USER_PAR="DiskSize"
USER_VAL=$((${USER_VAL}*1024));
SYS_VAL=`$CC_STATUS_FLAG | grep ${USER_PAR} | awk -F" " '{print $2}'`
echo "CompCache: $USER_PAR "$SYS_VAL"(system) "$USER_VAL"(user)"

elif [ $USER_PAR != "cc_disksize" ] && [ ${cc_backingswap_en} -eq 1 ] ; then
if [ $USER_PAR == "cc_memlimit" ]; then
USER_PAR="MemLimit"
USER_VAL=$((${USER_VAL}*1024));
SYS_VAL=`$CC_STATUS_FLAG | grep ${USER_PAR} | awk -F" " '{print $2}'`
echo "CompCache: $USER_PAR "$SYS_VAL"(system) "$USER_VAL"(user)"
elif [ $USER_PAR == "cc_backingswap" ] && [ ${CC_NEW_DECT} -eq 1 ]; then
USER_PAR="BackingSwap"
SYS_VAL=`$CC_STATUS_FLAG | grep ${USER_PAR} | awk -F" " '{print $2}'`
echo "CompCache: $USER_PAR "$SYS_VAL"(system) "$USER_VAL"(user)"
else
USER_PAR="DiskSize"
SYS_VAL=`$CC_STATUS_FLAG | grep ${USER_PAR} | awk -F" " '{print $2}'`
echo "CompCache: Backing_swap "$USER_VAL" , size $SYS_VAL"
fi

fi;

# backing swap detection is still missing
done

echo
echo === CompCache status output ===
$CC_STATUS_FLAG

elif [ $compcache_en -eq 1 ]; then
CC_SWAPOFF;

cc_disksize=$((${cc_disksize}*1024));
CC_DISKSIZE_FLAG="disksize_kb=${cc_disksize}";
cc_memlimit=$((${cc_memlimit}*1024));
CC_MEMSIZE_FLAG="memlimit_kb=${cc_memlimit}";
CC_BACKINGSWAP_FLAG="backing_swap=${cc_backingswap}";

if [ ${cc_backingswap_en} -eq 1 ] && [ -e ${cc_backingswap} ]; then
CC_DISKSIZE_FLAG="";
else
CC_MEMSIZE_FLAG="";
CC_BACKINGSWAP_FLAG="";
fi;

CHK_KERNEL_MOD_DIR;
if [ ${CC_NEW_DECT} -eq 0 ]; then
$insmod $MODDIR/compcache/xvmalloc.ko;
$insmod $MODDIR/compcache/ramzswap.ko ${CC_DISKSIZE_FLAG} ${CC_MEMSIZE_FLAG} ${CC_BACKINGSWAP_FLAG};
echo $insmod $MODDIR/compcache/ramzswap.ko ${CC_DISKSIZE_FLAG} ${CC_MEMSIZE_FLAG} ${CC_BACKINGSWAP_FLAG};
mknod ${CC_DEVICE} b 253 0;
else
if [ ! -z ${CC_DISKSIZE_FLAG} ]; then CC_DISKSIZE_FLAG="--${CC_DISKSIZE_FLAG}"; fi;
if [ ! -z ${CC_MEMSIZE_FLAG} ]; then CC_MEMSIZE_FLAG="--${CC_MEMSIZE_FLAG}"; fi;
if [ ! -z ${CC_BACKINGSWAP_FLAG} ]; then CC_BACKINGSWAP_FLAG="--${CC_BACKINGSWAP_FLAG}"; fi;
modprobe ramzswap
rzscontrol ${CC_DEVICE} ${CC_DISKSIZE_FLAG} ${CC_MEMSIZE_FLAG} ${CC_BACKINGSWAP_FLAG} --init;

echo "rzscontrol ${CC_DEVICE} ${CC_DISKSIZE_FLAG} ${CC_MEMSIZE_FLAG} ${CC_BACKINGSWAP_FLAG} --init";
fi;

#echo $swappiness > /proc/sys/vm/swappiness
sysctl -w vm.swappiness=${cc_swappiness};
#echo 20 > /proc/sys/vm/swappiness
swapon ${CC_DEVICE};
elif [ $compcache_en -eq 0 ]; then
CC_SWAPOFF;
fi;
}

SWAPFILE_CHK()
{
if [ ! -e ${linux_swap_file} ] && [ ${swap_file_en} -eq 1 ]; then
linux_swap_file_size=$((${linux_swap_file_size}*1024));
echo "Creating swap file: ${linux_swap_file}"
dd if=/dev/zero of=${linux_swap_file} bs=1024 count=${linux_swap_file_size}
mkswap ${linux_swap_file}
if [ -e ${linux_swap_file} ]; then
echo "SWAP file "${linux_swap_file}" created "
else
echo "ERROR!!! Unable to create swapfile "${linux_swap_file}""
fi;
elif [ -e ${linux_swap_file} ] && [ ${swap_file_en} -eq 1 ]; then
LINUXSWAP_OFF;
#mkswap ${linux_swap_file}
elif [ -e ${linux_swap_file} ] && [ ${swap_file_en} -eq 0 ]; then
LINUXSWAP_OFF;
echo Remove "${linux_swap_file}"
rm ${linux_swap_file}
fi;

}

LINUXSWAP_OFF()
{
LINUX_SWAP_ON=$(cat /proc/swaps | grep ${linux_swap_partition} | wc -l);
if [ $STATUS_CHK -eq 0 ] && [ ${LINUX_SWAP_ON} -eq 1 ]; then
swapoff ${linux_swap_partition};
echo swapoff ${linux_swap_partition};
fi;
}

# set linux swap
LINUXSWAP()
{
if [ $STATUS_CHK -eq 1 ] && [ ${linux_swap_en} -eq 1 ]; then
echo
echo === Linux Swap status ===
for i in $linux_swap_pars;
do
USER_VAL=$(echo $i | awk -F"=" '{print $2}');
USER_PAR=$(echo $i | awk -F"=" '{print $1}');
if [ $USER_PAR == "linux_swap_partition" ]; then
if [ ! -n ${USER_VAL} ]; then
echo !!! Linux SWAP error :${USER_VAL} is not a device node;
fi;
LINUX_SWAP_ON=$(cat /proc/swaps | grep ${USER_VAL} | wc -l);
if [ ${LINUX_SWAP_ON} -ne 1 ]; then
echo !!! Linux SWAP error: Linux swap is not enabled;
else
echo Linux SWAP enabled on ${USER_VAL}
fi;
fi;

if [ $USER_PAR == "swappiness" ]; then
SYS_VAL=`cat /proc/sys/vm/swappiness`
if [ $USER_VAL -ne $swappiness ] && [ ${compcache_en} -eq 1 ]; then
USER_VAL=$swappiness
echo "Use CompCache swappiness (cc_swappiness) $swappiness as default swappiness"
fi;
if [ $USER_VAL -ne "$SYS_VAL" ] || [ -z $SYS_VAL ]; then
echo "ERROR!!! Set Linux Swap: $USER_PAR - "$SYS_VAL"(system) "$USER_VAL"(user)"
else
echo "Linux Swap: $USER_PAR - "$SYS_VAL"(system) "$USER_VAL"(user)"
fi;
fi;
done

elif [ ${linux_swap_en} -eq 1 ] && [ ${cc_backingswap_en} -eq 0 ]; then
LINUXSWAP_OFF;

if [ -n ${linux_swap_partition} ] && [ ${swap_file_en} -eq 0 ]; then
echo mkswap ${linux_swap_partition};
mkswap ${linux_swap_partition};
fi;
echo ${swappiness} > /proc/sys/vm/swappiness;
echo swapon ${linux_swap_partition};
swapon ${linux_swap_partition};
elif [ ${linux_swap_en} -eq 0 ] ; then
LINUXSWAP_OFF;
fi;
}

# set virtual memory
SET_VM()
{
if [ $STATUS_CHK -eq 1 ] && [ ${sys_vm_en} -eq 1 ]; then
echo
echo === VM status ===
for i in $sys_vm_pars;
do
USER_VAL=$(echo $i | awk -F"=" '{print $2}');
USER_PAR=$(echo $i | awk -F"=" '{print $1}');
if [ $USER_PAR == "page_cluster" ]; then USER_PAR=page-cluster; fi;
SYS_VAL=`cat /proc/sys/vm/"$USER_PAR"`
if [ $USER_VAL -ne "$SYS_VAL" ] || [ -z $SYS_VAL ]; then
echo "ERROR!!! Set VM: $USER_PAR - "$SYS_VAL"(system) "$USER_VAL"(user)"
else
echo "Set VM: $USER_PAR - "$SYS_VAL"(system) "$USER_VAL"(user)"
fi;
done

elif [ ${sys_vm_en} -eq 1 ] && [ ${sys_vm} -eq 1 ];
then
echo ${page_cluster} > /proc/sys/vm/page-cluster;
echo ${laptop_mode} > /proc/sys/vm/laptop_mode;
echo ${dirty_expire_centisecs} > /proc/sys/vm/dirty_expire_centisecs;
echo ${dirty_writeback_centisecs} > /proc/sys/vm/dirty_writeback_centisecs;
echo ${dirty_background_ratio} > /proc/sys/vm/dirty_background_ratio;
echo ${dirty_ratio} > /proc/sys/vm/dirty_ratio;
fi;
}

#set cpu frequeency
SET_CPU()
{
if [ $STATUS_CHK -eq 1 ] && [ ${proc_cpu_en} -eq 1 ]; then
echo
echo === CPU status ===
for i in $proc_cpu_pars;
do
USER_VAL=$(echo $i | awk -F"=" '{print $2}');
USER_PAR=$(echo $i | awk -F"=" '{print $1}');
if [ $(echo $USER_PAR | grep freq | wc -l) -ge 1 ]; then
SYS_VAL=`cat /sys/devices/system/cpu/cpu0/cpufreq/"$USER_PAR"`
else
SYS_VAL=`cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/"$USER_PAR"`
fi
if [ $USER_VAL -ne "$SYS_VAL" ] || [ -z $SYS_VAL ]; then
echo "ERROR!!! Set CPU: $USER_PAR - "$SYS_VAL"(system) "$USER_VAL"(user)"
else
echo "Set CPU: $USER_PAR - "$SYS_VAL"(system) "$USER_VAL"(user)"
fi;
done

elif [ ${proc_cpu_en} -eq 1 ] && [ ${proc_cpu} -eq 1 ]; then
echo ${sampling_rate} > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
echo ${scaling_min_freq} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo ${scaling_max_freq} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo ${powersave_bias} > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias;
echo ${up_threshold} > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold;
fi;

}
SYS_INFO ()
{
if [ ${DISP_SYS_INFO} -eq 1 ]; then
echo
echo === free ===
free
echo
echo === swaps ===
cat /proc/swaps
echo
echo === ${CC_STATUS_FLAG} ===
${CC_STATUS_FLAG}
echo
echo === meminfo ===
cat /proc/meminfo
echo
echo === VM configurations ===
sysctl -a | grep vm
echo
echo === CPU Configuratons ===
echo -n up_threshold: \ & cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo -n sampling_rate: \ & cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo -n powersave_bias: \ & cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
echo -n scaling_cur_freq: \ & cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
echo
echo === cpu stats ===
echo time_in_state:
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
echo
echo trans_table:
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table
exit 0;
fi

}

FIX_PERMISSIONS()
{
#base of CM's permfixer.sh
if [ $STATUS_CHK -eq 0 ] && [ ${permission_fix} -eq 1 ]; then
MOUNT_CHK;
echo "Fix permissions for application pacakges"
cat /data/system/packages.xml | grep "^<package" | grep serId | grep -v framework-res.apk | sed 's/>//g' | sed 's/<name//g' | while read line; do
name="";
codePath="";
system=""
ts="";
userId="";
sharedUserId=""
for i in $( echo $line | tr " " "\n" ); do
if [ -n "$(echo $i | awk -F"=" '{print $2}')" ]; then
eval $i
fi;
done
if [ -z "${userId}" ]; then
UID=$sharedUserId
else
UID=$userId
fi;
SYSTEM_APP=$( echo "$codePath" | grep /system/app | wc -l)
DATA_APP=$( echo "$codePath" | grep /data/app |wc -l )
DATA_PAPP=$( echo "$codePath" | grep /data/app-private | wc -l)

if [ -e "$codePath" ]; then
# Fix permision for application packages
if [ "$SYSTEM_APP" -eq 1 ]; then
busybox chown 0:0 $codePath
busybox chmod 644 "$codePath"
elif [ "$DATA_APP" -eq 1 ]; then
busybox chown 1000:0 $codePath
busybox chmod 644 "$codePath"
elif [ "$DATA_PAPP" -eq 1 ]; then
busybox chown 0:${UID} $codePath
busybox chmod 640 "$codePath"
fi

# permission fix for all directories under package data
busybox chown -R $UID:$UID /data/data/$name;
# revert lib directory permissions
if [ -e "$/data/data/$name/lib" ]; then
busybox chown -R 1000:1000 "/data/data/$name/lib";
fi
else
$ECHO "$codePath does not exist. Please reinstall application($name)."
fi
done
sed -i 's/permission_fix=1/permission_fix=0/g' ${CONF_FILE}
echo "Permission fixed!!!"
fi;
}

ODEX_GEN()
{
if [ $odex_all -eq "1" ] || [ $odex_apk -eq "1" ]; then
MOUNT_CHK;
dalvik=`cat /proc/mounts | grep dalvik-cache | awk -F" " '{print $2}'`
for i in $app_dirs
do
if [ -d $i ]; then
if [ $odex_all -eq "1" ]; then
rm $i/*.odex
fi;
for j in $i/*.apk
do
odex=`echo $j | sed -e 's/.apk/.odex/g'`
dex=`echo $j | cut -c2- | sed -e 's/\//@/g'| sed -e 's/.apk/*.dex/g'`
if [ -f $j ] ;then
if [ $odex_all -eq "1" ]; then
echo "--- dexopt-wrapper $j $odex"
dexopt-wrapper $j $odex
if [ -f "$dalvik/$dex" ]; then
echo "--- rm $dalvik/$dex"
rm $dalvik/$dex
fi;
elif [ $odex_apk -eq "1" ] && [ ! -f $odex ]; then
echo "--- dexopt-wrapper $j $odex"
dexopt-wrapper $j $odex
if [ -f "$dalvik/$dex" ]; then
echo "--- rm $dalvik/$dex"
rm $dalvik/$dex
fi;
fi;
fi;
done
fi;
done

sed -i 's/odex_apk=1/odex_apk=0/g' ${CONF_FILE}
sed -i 's/odex_all=1/odex_all=0/g' ${CONF_FILE}
fi;
}

AUTO_ODEX()
{
for i in $app_dirs
do
if [ -d $i ]; then
find $i/*.apk -mtime -3 | while read apk;
do
odex=`echo $apk | sed -e 's/.apk/.odex/g'`
dex=`echo $apk | cut -c2- | sed -e 's/\//@/g'| sed -e 's/.apk/*.dex/g'`
APK_TIME=`stat $apk |grep Modify| awk -F" " '{print $2$3}'| awk -F"." '{print $1}'|sed -e 's/-//g' -e 's/://g'`
if [ -f "$odex" ]; then
ODEX_TIME=`stat $odex |grep Modify| awk -F" " '{print $2$3}'| awk -F"." '{print $1}'|sed -e 's/-//g' -e 's/://g'`
if [ ${ODEX_TIME} -le ${APK_TIME} ]; then
echo "--- rm $odex"
rm $odex
echo "--- dexopt-wrapper $j $odex"
dexopt-wrapper $apk $odex
if [ -f "$dalvik/$dex" ]; then
echo "--- rm $dalvik/$dex"
rm $dalvik/$dex
fi;
fi;
elif [ $odex_auto -eq "1" ]; then
echo "--- dexopt-wrapper $j $odex"
dexopt-wrapper $apk $odex
fi;
done

find $i/*.odex -mtime -7 | while read odex;
do
apk=`echo $odex | sed -e 's/.odex/.apk/g'`
#remove odex when application has been unistalled
if [ ! -f "$apk" ]; then
echo "--- rm $odex"
rm $odex
fi;

done
fi;
done

}

MOUNT_CHK()
{
system_chk=`cat /proc/mounts | grep "/system " | awk -F" " '{print $4}'`
data_chk=`cat /proc/mounts | grep "/data " | awk -F" " '{print $4}'`

if [ "$system_chk" == "ro" ]; then
mount -o remount,rw /dev/block/mtdblock3 /system
fi
if [ "$data_chk" == "ro" ]; then
mount -o remount,rw /dev/block/mtdblock5 /data
fi
}

USER_CMD()
{
i=1;
while [ $i -ne 0 ];
do
i=$((${i}+1));
cmd=`echo $custom_shells_pars | cut -d "#" -f $i`
if [ -z "$cmd" ]; then
i=0;
else
/system/bin/sh -c "$cmd"
fi;
done
}

#main program
parse_args $*
GET_USER_CONF;
USER_CONF_CHECK;
SYS_INFO;

MEDIA2SD;
SWAPFILE_CHK;
COMPCACHE;
LINUXSWAP;
SET_VM;
SET_CPU;
FIX_PERMISSIONS;
ODEX_GEN;
AUTO_ODEX;
USER_CMD;
symbolic_link;
mount -o remount,ro /dev/block/mtdblock3 /system
exit 0;