#!/bin/sh
#Herminux script to unmount block devices easily with 'mnt <devicename>' command
#(Works best with /mnt as a temporary filesystem, so no disk-writes needed)

#print help and return if no parameters given
if [ $# -eq 0 ] ; then 
 echo "__________________________________________________________________"
 echo " Herminux unmounter. Usage: umnt <devicename without /dev/ prefix>" ; 
 echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
 exit 0
fi

echo "Unmounting /dev/$1 (from /mnt/$1)"
umount /dev/$1

#delete mountpoint-directory (only if it is empty aka unmounted)
if [ -d /mnt/$1 ] ; then
 rmdir /mnt/$1
fi
