#!/system/bin/sh
#
# bind mount /cache to /system/sd/cache
# leo@kloburg.at

if grep -q " /system/sd " /proc/mounts; then
    busybox mkdir /system/sd/cache;
    busybox chown 1000:2001 /system/sd/cache;
    busybox chmod 770 /system/sd/cache;
    if [ -d /cache/dalvik-cache ] && [ ! -d /system/sd/cache/dalvik-cache ]; then
      busybox cp -a /cache/dalvik-cache /system/sd/cache/;
      busybox rm -f /cache/dalvik-cache/*;
      busybox rmdir /cache/dalvik-cache;
    fi
    busybox mount -obind /system/sd/cache /cache;
fi
