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

#First see if a device is mounted 
if `mount | grep /dev/sdc >/dev/null`; then
   #Next check to see what type it is based on class
   /bin/sync
   sleep 2
   /bin/sync
   if `umount /dev/sdc1 >>$usb_log 2>&1`; then
      echo `date` " /dev/sdc1 unmounted" >>$usb_log
      rmdir /mnt/usb/
      exit 0
   else #/dev/sdc1 device failed to unmount
      umountrc=$?
      nCount=0
      while [ $umountrc -ne 0 -a $nCount -lt 4 ]; do
         /bin/sync
         sleep 2
         umount /dev/sdc1 >>$usb_log 2>&1
         umountrc=$?
         (( nCount += 1))
      done
      if [ $umountrc -ne 0 ]; then
         echo `date` " Device /dev/sdc1 failed to unmount with rc $umountrc - device busy?" >>$usb_log
         exit 1
      fi
   fi
else
   echo 'date' " no device mounted at /dev/sdc1, cannot unmount" >>$usb_log
   exit 0
fi

