Advertisement
Guest User

04apx2sd

a guest
Aug 27th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.53 KB | None | 0 0
  1. #!/system/bin/sh
  2. #
  3. # Apps2SD using symlinks and bind mounts
  4. # [email protected] (cyanogen)
  5. # Adapted by Teknologist
  6. # fixed autoformat mmcblk0p2 to ext2 by Kalashnikitty
  7.  
  8. #Removed this as there is no /etc/sysctl.conf as of now in MCR
  9.  
  10. # execute any postinstall script then kill it
  11. if [ -e /dev/block/mmcblk0p2 ];
  12. then
  13.  
  14.     # mount and set perms
  15.     busybox mount -o noatime,nodiratime,nosuid,nodev,noauto_da_alloc,nouser_xattr,errors=continue -t auto /dev/block/mmcblk0p2 /sd-ext;
  16.     busybox chown 1000:1000 /sd-ext;
  17.     busybox chmod 771 /sd-ext;
  18.  
  19.     # clean up any old symlinks, create data directories
  20.     for i in data;
  21.     do
  22.         if [ -h /data/$i ];
  23.         then
  24.             rm /data/$i;
  25.         fi;
  26.         if [ ! -d /data/$i ];
  27.         then
  28.             mkdir /data/$i;
  29.             busybox chown 1000:1000 /data/$i;
  30.             busybox chmod 771 /data/$i;
  31.         fi;
  32.     done;
  33.  
  34.     # don't allow /data/data on sd because of upgrade issues - move it if possible
  35.     if [ -d /sd-ext/data ];
  36.     then
  37.         busybox cp -a /sd-ext/data/* /data/data/;
  38.         busybox rm -rf /sd-ext/data;
  39.     fi;
  40.  
  41.     # move apps from internal memory to sdcard
  42.     for i in app app-private;
  43.     do
  44.         if [ ! -d /sd-ext/$i ];
  45.         then
  46.             mkdir /sd-ext/$i;
  47.         fi
  48.  
  49.         busybox chown 1000:1000 /sd-ext/$i;
  50.         busybox chmod 771 /sd-ext/$i
  51.        
  52.         if [ -d /data/$i ] && [ ! -h /data/$i ];
  53.         then
  54.             busybox cp -a /data/$i/* /sd-ext/$i/;
  55.             busybox rm -f /data/$i/*;
  56.         fi;
  57.     done;
  58.  
  59.     # symlink app dirs - they must be on the same filesystem
  60.     for i in app app-private;
  61.     do
  62.         if [ -d /data/$i ] && [ ! -h /data/$i ];
  63.         then
  64.             busybox rm -rf /data/$i;
  65.             busybox ln -s /sd-ext/$i /data/$i;
  66.         fi;
  67.     done;
  68.  
  69.     # clean up old whiteouts
  70.     for i in local misc property system tombstones data;
  71.     do
  72.         if [ -h /sd-ext/$i ]; then rm -f /sd-ext/$i; fi
  73.     done;
  74.  
  75.     # please don't put odex files in the app directory people!
  76.     # it causes dexopt to crash when switching builds!
  77.     busybox rm -f /sd-ext/app/*.odex
  78.  
  79.     setprop cm.a2sd.active 1;
  80.    
  81.     echo "+++ Apps-to-SD successfully enabled";
  82.  
  83. else
  84.    
  85.     # replace symlinks with directories so we can boot without sd
  86.     for i in app app-private;
  87.     do
  88.        if [ -h /data/$i ];
  89.        then
  90.             rm -f /data/$i;
  91.             mkdir /data/$i;
  92.             busybox chown 1000:1000 /data/$i;
  93.             busybox chmod 771 /data/$i;
  94.         fi;
  95.     done;
  96.  
  97.  
  98.     setprop cm.a2sd.active 0;
  99. fi;
  100.  
  101.  
  102. sync;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement