Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/system/bin/sh
- mountdir=/mnt/Usb_otg
- # checks number of dirs in media_rw
- n=`ls -ld /mnt/media_rw/* | wc -l`
- # if more than one quits
- if [ $n -gt 1 ] ; then echo error: more then one mount point in /mnt/media_rw - exiting && exit 1; fi
- if [ $n -lt 1 ] ; then echo error: no mount point in /mnt/media_rw - exiting && exit 1; fi
- # gets the mount point of the USB OTG pendrive
- mountpoint=`ls -d /mnt/media_rw/*`
- # finds the device name of the pendrive
- if [ -d $mountpoint ] ; then device=`mount | grep $mountpoint | cut -d' ' -f1`; fi
- # check if usb_otg dir exists, if not creates it
- if [ ! -d $mountdir ] ; then
- mkdir $mountdir
- chmod 777 $mountdir
- fi
- # unmount mount point
- umount $mountpoint
- if [ $? -ne 0 ] ; then
- echo error: unmouting failed - exiting
- exit 1
- fi
- # checks exit code and re-mounts device on new mount point.
- # At last, removes the now empty old mount point
- if [ $? -eq 0 ] ; then
- mount $device $mountdir
- if [ $? -ne 0 ] ; then
- echo error: mouting failed - exiting
- exit 1
- fi
- rmdir $mountpoint
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement