Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/system/bin/sh
- # MAD Team App2SD (Cyanogen 7)
- # by subpsyke
- swapfile="/system/etc/init.d/06swap"
- LOG="/dev/null"
- checkapp2sd() {
- mount -t ext4 -o nodev,nosuid /dev/block/mmcblk0p2 /system/sd
- if [ -f /system/sd/.app2sd_enabled ]; then
- result="app2sd"
- else
- result="normal"
- fi
- }
- checkspace() {
- sdused=`du -c /system/sd/ | tail -n1 | awk ' { print $1 } '`
- sdfree=`df /system/sd/ | tail -n1 | awk ' { print $4 } '`
- phoneused=`du -c /data | tail -n1 | awk ' { print $1 } '`
- phonefree=`df /data | tail -n1 | awk ' { print $4 } '`
- }
- convert_app2sd() {
- mount -t ext4 -o nodev,nosuid /dev/block/stl13 /data
- sleep 5
- rm -r /data
- sync
- sleep 5
- cp -a /system/sd/data /
- sync
- sleep 5
- umount /dev/block/mmcblk0p2
- mke2fs -t ext4 -O ^huge_file /dev/block/stl14
- sleep 5
- mke2fs -t ext4 -O ^huge_file /dev/block/mmcblk0p2
- sleep 5
- }
- convert_normal() {
- umount /dev/block/mmcblk0p2
- mke2fs -O journal_dev /dev/block/stl14
- sleep 5
- mke2fs -t ext4 -O ^huge_file -J device=/dev/block/stl14 /dev/block/mmcblk0p2
- sleep 5
- mount -t ext4 -o nodev,nosuid /dev/block/mmcblk0p2 /system/sd
- mount -t ext4 -o nodev,nosuid /dev/block/stl13 /data
- sleep 5
- cp -a /data /system/sd/
- sync
- sleep 5
- rm -r /data
- sync
- sleep 5
- touch /system/sd/.app2sd_enabled
- }
- mount_normal() {
- mount -t ext4 -o nodev,nosuid /dev/block/stl13 /data
- mount -t ext4 -o nodev,nosuid /dev/block/stl14 /cache
- }
- mount_app2sd() {
- umount -a
- mount -t ext4 -o nodev,nosuid /dev/block/stl14 /cache
- if mount | grep /dev/block/stl14 | grep cache; then
- umount /dev/block/stl14
- mke2fs -O journal_dev /dev/block/stl14
- tune2fs -J device=/dev/block/stl14 /dev/block/mmcblk0p2
- fi
- mount -t ext4 -o nodev,nosuid /dev/block/mmcblk0p2 /system/sd
- mkdir /system/sd/data
- mount -o bind /system/sd/data /data
- mount -t ext4 -o nodev,nosuid /dev/block/stl13 /cache
- }
- doboot() {
- # Run checks
- checkapp2sd
- # Toggle App2SD
- if [ -f /system/sd/.toggleapp2sd ]; then
- rm /system/sd/.toggleapp2sd
- stop
- convert_$result
- if [ "$result" = "normal" ]; then
- result="app2sd"
- else
- result="normal"
- fi
- sleep 5
- stop
- sync
- umount -a
- sync
- stop
- sleep 5
- reboot
- fi
- mount_$result
- }
- if [ "$1" = "" ]; then
- checkapp2sd
- checkspace
- echo ""
- echo "Usage: madteam_app2sd [option]"
- echo "Options:"
- echo ""
- echo " * toggle - disable/enable App2SD"
- echo " * swapon - enable swap"
- echo " * swapoff - disable swap"
- echo ""
- echo "MAD Team App2SD status:"
- echo ""
- if [ "$result" = "app2sd" ]; then
- echo "App2SD: activated"
- echo "SD card used: $sdused""KB"
- echo "SD card free: $sdfree""KB"
- else
- echo "App2SD: deactivated"
- echo "Phone used: $phoneused""KB"
- echo "Phone free: $phonefree""KB"
- fi
- echo "Swap size: " `free | grep Swap | awk ' { print ($2) } '`"KB"
- echo ""
- fi
- mkdir /system/sd 1>>$LOG 2>>$LOG
- if [ "$1" = "doboot" ]; then
- doboot
- fi
- if [ "$1" = "swapon" ]; then
- echo "#!/system/bin/sh" >$swapfile
- echo "swapon /dev/block/mmcblk0p3" >$swapfile
- chmod +x $swapfile
- $swapfile
- echo "Swap enabled! Setting will be kept on reboot."
- fi
- if [ "$1" = "swapoff" ]; then
- echo "#!/system/bin/sh" >$swapfile
- echo "swapon /dev/block/mmcblk0p3" >$swapfile
- chmod -x $swapfile
- swapoff /dev/block/mmcblk0p3
- echo "Swap disabled! Setting will be kept on reboot."
- fi
- if [ "$1" = "toggle" ]; then
- checkapp2sd
- checkspace
- if [ "$result" = "app2sd" ]; then
- echo "Current App2SD status: activated"
- echo ""
- echo "SD card used: $sdused""KB"
- echo "Phone free: $phonefree""KB"
- echo ""
- if [ $(($sdused)) -gt $(($phonefree)) ]; then
- echo "Not enough space in phone memory to complete operation!"
- echo "Please free " $(($sdused-$phonefree)) "KB from SD card's App2SD partition to continue."
- echo "Aborting!"
- else
- echo "Please reboot your phone to deactivate App2SD."
- echo "Note: your phone will reboot twice. This is normal."
- touch /system/sd/.toggleapp2sd
- fi
- fi
- if [ "$result" = "normal" ]; then
- echo "Current App2SD status: deactivated"
- echo ""
- echo "Phone used: $phoneused""KB"
- echo "SD card free: $sdfree""KB"
- echo ""
- if [ $(($phoneused)) -gt $(($sdfree)) ]; then
- echo "Not enough space on SD card partition to complete operation!"
- echo "Please free " $(($phoneused-$sdfree)) "KB from Phone to continue."
- echo "Aborting!"
- else
- echo "Please reboot your phone to activate App2SD."
- echo "Note: your phone will reboot twice. This is normal."
- touch /system/sd/.toggleapp2sd
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement