132 lines
3.2 KiB
Plaintext
132 lines
3.2 KiB
Plaintext
|
#!/system/xbin/busybox sh
|
||
|
#
|
||
|
# Apps2SD using symlinks and bind mounts
|
||
|
# Originally by cyanogen (shade@chemlab.org)
|
||
|
# Modified by teppic74 / xda
|
||
|
# Debugging version 1.4
|
||
|
# MDJ's CyanogenMod 7 v. 1.9
|
||
|
|
||
|
|
||
|
SD=/sd-ext
|
||
|
|
||
|
busybox grep 'sdcard auto' /system/etc/vold.fstab >/dev/null
|
||
|
if [ $? -eq 0 ] ; then
|
||
|
echo "+++ A2SD: WARNING: File corruption possible with USB disk mode"
|
||
|
else
|
||
|
echo "+++ A2SD: Safe to use USB disk mode"
|
||
|
fi
|
||
|
|
||
|
|
||
|
# execute any postinstall script then kill it
|
||
|
if [ -e /dev/block/mmcblk0p2 ];
|
||
|
then
|
||
|
echo "+++ Starting A2SD+"
|
||
|
# mount and set perms
|
||
|
busybox mount -o noatime,nodiratime -t auto /dev/block/mmcblk0p2 $SD
|
||
|
# Shouldn't proceed if mount fails!
|
||
|
if [ $? -eq 0 ]; then
|
||
|
busybox chown 1000:1000 $SD;
|
||
|
busybox chmod 771 $SD;
|
||
|
|
||
|
# clean up any old symlinks, create data directories
|
||
|
for i in data;
|
||
|
do
|
||
|
if [ -h /data/$i ];
|
||
|
then
|
||
|
echo "+++ A2SD: 28: removing simlink /data/$i"
|
||
|
rm /data/$i;
|
||
|
fi;
|
||
|
if [ ! -d /data/$i ];
|
||
|
then
|
||
|
echo "+++ A2SD: 33: creating /data/$i"
|
||
|
mkdir /data/$i;
|
||
|
busybox chown 1000:1000 /data/$i;
|
||
|
busybox chmod 771 /data/$i;
|
||
|
fi;
|
||
|
done;
|
||
|
|
||
|
# don't allow /data/data on sd because of upgrade issues - move it if possible
|
||
|
if [ -d $SD/data ];
|
||
|
then
|
||
|
echo "+++ A2SD: 43: SD data found"
|
||
|
busybox cp -a $SD/data/* /data/data/;
|
||
|
busybox rm -rf $SD/data;
|
||
|
fi;
|
||
|
|
||
|
# move apps from internal memory to sdcard
|
||
|
for i in app app-private dalvik-cache;
|
||
|
do
|
||
|
if [ ! -d $SD/$i ];
|
||
|
then
|
||
|
echo "+++ A2SD: 53: Creating $SD/$i"
|
||
|
mkdir $SD/$i;
|
||
|
fi
|
||
|
|
||
|
busybox chown 1000:1000 $SD/$i;
|
||
|
busybox chmod 771 $SD/$i
|
||
|
|
||
|
if [ -d /data/$i ] && [ ! -h /data/$i ];
|
||
|
then
|
||
|
busybox cp -ap /data/$i/* $SD/$i/;
|
||
|
busybox rm -f /data/$i/*;
|
||
|
fi;
|
||
|
done;
|
||
|
|
||
|
# symlink app dirs - they must be on the same filesystem
|
||
|
for i in app app-private dalvik-cache;
|
||
|
do
|
||
|
if [ -d /data/$i ] && [ ! -h /data/$i ];
|
||
|
then
|
||
|
busybox rm -rf /data/$i;
|
||
|
busybox ln -s $SD/$i /data/$i;
|
||
|
fi;
|
||
|
done;
|
||
|
|
||
|
# clean up old whiteouts
|
||
|
for i in local misc property system tombstones data;
|
||
|
do
|
||
|
if [ -h $SD/$i ]; then rm -f $SD/$i; fi
|
||
|
done;
|
||
|
|
||
|
# please don't put odex files in the app directory people!
|
||
|
# it causes dexopt to crash when switching builds!
|
||
|
busybox rm -f $SD/app/*.odex
|
||
|
|
||
|
setprop cm.apps2sd.active 1;
|
||
|
|
||
|
echo "+++ A2SD+ successfully enabled";
|
||
|
else
|
||
|
echo "+++ A2SD+ mount FAILED -- format your ext partition"
|
||
|
for i in app app-private dalvik-cache
|
||
|
do
|
||
|
if [ -h /data/$i ]
|
||
|
then
|
||
|
rm -f /data/$i
|
||
|
mkdir /data/$i
|
||
|
busybox chown 1000:1000 /data/$i
|
||
|
busybox chmod 771 /data/$i
|
||
|
fi
|
||
|
done
|
||
|
setprop cm.apps2sd.active 0
|
||
|
fi
|
||
|
else
|
||
|
|
||
|
# replace symlinks with directories so we can boot without sd
|
||
|
for i in app app-private dalvik-cache
|
||
|
do
|
||
|
if [ -h /data/$i ]
|
||
|
then
|
||
|
rm -f /data/$i
|
||
|
mkdir /data/$i
|
||
|
busybox chown 1000:1000 /data/$i
|
||
|
busybox chmod 771 /data/$i
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
|
||
|
setprop cm.apps2sd.active 0
|
||
|
fi
|
||
|
|
||
|
|
||
|
sync
|