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

#print help and return if no parameters given
if [ $# -eq 0 ] ; then 
 echo "_______________________________________________________________"
 echo " Herminux mounter. Usage: mnt <devicename without /dev/ prefix>"
 echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
 echo "The currently seen devices and partitions to mount:"
 echo "---------------------------------------------------"
 fdisk -l
 echo " "
 echo "The mounted devices/partitions (with used & available space info):"
 echo "------------------------------------------------------------------"
 df -a -h
 exit 0
fi

if [ ! -e /dev/$1 ] ; then
 echo "Couldn't find device /dev/$1."
 exit 1
fi

echo "Found device /dev/$1. Mounting it on /mnt/$1"

mkdir -p /mnt/$1

mount /dev/$1 /mnt/$1

