#!/bin/sh
#easy to mount/umount usb storage
usage()
{
  echo "need root priority"
  echo "usage:`basename $0` -u(umount)"
  echo "     :`basename $0`   (mount)"
  exit -1
}
#test root priority
[ `id -u` != 0 ] && usage

if [ $# == 0 ]; then
#create mount directory
  lsblk -n -l -f|grep 'ntfs\|vfat\|exfat'|grep -v /mnt/|awk '{print "mkdir /mnt/"$(NF),"2>/dev/null"}'|'/bin/bash'
#mount the parition
  lsblk -n -l -f|grep 'ntfs\|vfat\|exfat'|grep -v /mnt/|awk '{print "mount -o gid=users,umask=000 -t",$2,"/dev/"$1,"/mnt/"$(NF),"2>/dev/null"}'|'/bin/bash'
#result output
  lsblk
  exit -1
fi


#umount the partition
if [ $# == 1 ]; then
    if [ ${1} == '-u' ]; then
        ls -1 /mnt/|awk '{print "umount /mnt/"$1,"2>/dev/null"}'|'/bin/bash'
    else
        usage
    fi
else
    usage
fi