echo checking if usb cable connected usbstate=$(cat /sys/class/android_usb/android0/state) if test "$usbstate" = "CONFIGURED" then echo cable connected echo echo unmounting ext-sd card from phone busybox umount /mnt/media_rw/external_SD busybox umount /mnt/secure/asec echo setting usb config to mass storage setprop persist.sys.usb.config mass_storage,adb echo mounting ext-sd card to pc mountstatus=$(cat /sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file) if test "$mountstatus" != "/dev/block/vold/179:65" then echo /dev/block/vold/179:65 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file fi echo usb mass storage connected echo #waiting for disconnection while test $usbstate = "CONFIGURED";do sleep 5 usbstate=$(cat /sys/class/android_usb/android0/state) done echo cable disconnected echo echo remounting ext-sd card to phone... busybox mount -t vfat -o rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,utf8 /dev/block/vold/179:65 /mnt/media_rw/external_SD busybox mount -t vfat -o rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,utf8 /dev/block/vold/179:65 /mnt/secure/asec echo mount complete echo end else echo cable not connected echo run script after connecting cable echo end fi