# This stuff only works with "usbmount" function doublecheck () { # Check to see whether it exists ;-) grep /media/usb"$CHECK" /etc/mtab > /dev/null 2>&1 if [ $? -ne 0 ] ; then echo echo "/media/usb"$CHECK" is not mounted, according to mtab" echo "Did you type the right number?" echo sleep 5 f-usb fi } function f-eject () { # See if there are actually any usb devices mounted as /media/usb* in /media ( /etc/mtab) grep /media/usb /etc/mtab > /dev/null 2>&1 if [ $? -ne 0 ] ; then echo echo "You don't seem to have any usb devices auto-mounted, according to mtab" sleep 5 f-usb fi # If we haven't just used/accessed a device, then ask... # Otherwise use the number we have already. (from f-access) if [ "$MOUNTPOINT" = "" ] ; then printf "\n\n" echo "Type the number of the device to eject - for instance 1 for /media/usb1" f-ttynum read -n 1 "EJECT" CHECK="$EJECT" doublecheck eject /media/usb"$CHECK" echo echo "Unmounting and ejecting... please wait" sleep 3 # not sure this is needed but lights flash for a while... echo else CHECK="$MOUNTPOINT" doublecheck eject /media/usb"$CHECK" echo echo "Unmounting and ejecting... please wait" sleep 3 # not sure this is needed but lights flash for a while... fi # Check mtab to see if the device actually unmounted and ejected grep /media/usb"$CHECK" /etc/mtab > /dev/null 2>&1 if [ $? -ne 0 ] ; then # OK, grep can't find it in /etc/mtab so it must be unmounted... green ; bold echo echo "It is now safe to remove the device that was mounted at /media/usb"$CHECK"" white sleep 4 else # Something wicked happened, or didn't happen... echo red ; bold echo "Your device seems not to have safely unmounted - please check" echo "if it is still shown mounted in the usb menu. Hit to see." white echo read fi f-usb }