usb_log="/var/log/mountusb.log"

#First see if a device is mounted 
if `mount | grep /dev/sda >/dev/null`; then
   #Next check to see what type it is based on class
   if `cat "/proc/bus/usb/devices" | grep Cls=08 >/dev/null 2>&1`; then
      if `umount /dev/sda1 >>$usb_log 2>&1`; then
         echo `date` " /dev/sdb1 unmounted" >>$usb_log
         rmdir /mnt/usb/
         exit 0
      else #/dev/sdb1 device failed to unmount
         umountrc=$?
         echo `date` " Device /dev/sda1 failed to unmount with rc $umountrc - device busy?" >>$usb_log
         exit 1
      fi
   fi
else
   echo 'date' " no device mounted at /dev/sda1, cannot unmount" >>$usb_log
   exit 0
fi

