Share Pastebin
Guest
Public paste!

ivanmmj

By: a guest | Feb 9th, 2010 | Syntax: Bash | Size: 3.21 KB | Hits: 148 | Expires: Never
Copy text to clipboard
  1. #!/system/bin/sh
  2. #
  3. # Enable Apps2SD
  4.  
  5. if [ -e /dev/block/mmcblk0p2 ];
  6. then
  7.     echo "--- Checking filesystems";
  8.  
  9.     # fsck the sdcard filesystem first
  10.     e2fsck -y /dev/block/mmcblk0p2;
  11.  
  12.     # set property with exit code in case an error occurs
  13.     setprop cm.e2fsck.errors $?;
  14.  
  15.     # mount and set perms
  16.     busybox mount -o noatime,nodiratime -t auto /dev/block/mmcblk0p2 /system/sd;
  17.     if [ "$?" = 0 ];
  18.     then
  19.         busybox chown 1000:1000 /system/sd;
  20.         busybox chmod 771 /system/sd;
  21.  
  22.         # clean up any old symlinks, create data directories
  23.         for i in dalvik-cache data;
  24.         do
  25.             if [ -h /data/$i ];
  26.             then
  27.                 rm /data/$i;
  28.             fi;
  29.             if [ ! -d /data/$i ];
  30.             then
  31.                 mkdir /data/$i;
  32.                 busybox chown 1000:1000 /data/$i;
  33.                 busybox chmod 771 /data/$i;
  34.             fi;
  35.         done;
  36.  
  37.         # don't allow /data/data on sd because of upgrade issues - move it if possible
  38.         if [ -d /system/sd/data ];
  39.         then
  40.             busybox cp -a /system/sd/data/* /data/data/;
  41.             busybox rm -rf /system/sd/data;
  42.         fi;
  43.  
  44.         # move apps and dalvik cache from internal memory to sdcard
  45.         #for i in app app-private dalvik-cache;
  46.                 for i in app app-private;
  47.         do
  48.             if [ ! -d /system/sd/$i ];
  49.             then
  50.                 mkdir /system/sd/$i;
  51.             fi
  52.  
  53.             busybox chown 1000:1000 /system/sd/$i;
  54.             busybox chmod 771 /system/sd/$i
  55.  
  56.             if [ -d /data/$i ] && [ ! -h /data/$i ];
  57.             then
  58.                 busybox cp -a /data/$i/* /system/sd/$i/;
  59.                 busybox rm -f /data/$i/*;
  60.             fi;
  61.         done;
  62.  
  63.         # symlink app dirs - they must be on the same filesystem
  64.         for i in app app-private;
  65.         do
  66.             if [ -d /data/$i ] && [ ! -h /data/$i ];
  67.             then
  68.                 busybox rm -rf /data/$i;
  69.                 busybox ln -s /system/sd/$i /data/$i;
  70.             fi;
  71.         done;
  72.  
  73.         # bind mount dalvik-cache so we can still boot without the sdcard
  74.         #busybox mount -o bind /system/sd/dalvik-cache /data/dalvik-cache;
  75.         #busybox chown 1000:1000 /data/dalvik-cache;
  76.         #busybox chmod 771 /data/dalvik-cache;
  77.  
  78.         # clean up old whiteouts
  79.         for i in local misc property system tombstones data;
  80.         do
  81.             if [ -h /system/sd/$i ]; then rm -f /system/sd/$i; fi
  82.         done;
  83.  
  84.         # please don't put odex files in the app directory people!
  85.         # it causes dexopt to crash when switching builds!
  86.         busybox rm -f /system/sd/app/*.odex
  87.  
  88.         setprop cm.a2sd.active 1;
  89.  
  90.         echo "+++ Apps-to-SD successfully enabled";
  91.     else
  92.         echo "*** Unable to mount filesystem for a2sd!";
  93.     fi
  94. fi
  95.  
  96. A2SD_ACTIVE=`getprop cm.a2sd.active`
  97.  
  98. if [ "$A2SD_ACTIVE" != 1 ];
  99. then
  100.     # replace symlinks with directories so we can boot without sd
  101.     for i in app app-private;
  102.     do
  103.        if [ -h /data/$i ];
  104.        then
  105.             rm -f /data/$i;
  106.             mkdir /data/$i;
  107.             busybox chown 1000:1000 /data/$i;
  108.             busybox chmod 771 /data/$i;
  109.         fi;
  110.     done;
  111. fi;