
#!/system/bin
#
# Script to move all apps in the SD FAT to the /sd-ext (internal memory)
#
# Usage: all2sdext
#
# Author: Michelasso @ androidiani.com
#
# Version: 1.0

# Check if S2SD directories are mounted
if [ "$(mount | grep /data/app)" == "" ] || [ "$(mount | grep /sd-ext)" == "" ]; then
	echo "This script requires Switch2SD (S2SD) to be installed and running at boot time" 
	echo "Exiting..."
	exit 2
fi

# Check if any application is installed in the SD FAT
if [ "$(mount | grep /mnt/asec | grep -vw tmpfs)" == "" ]; then
	echo "No applications to move."
	echo "Exiting..."
	exit 0
fi

# Move all SD FAT applications back to the "internal memory"
echo "Moving applications back to the internal memory"
for app in /mnt/asec/*/pkg.apk; do
	pm install -r -f $app
done
