#!/bin/sh
# usbhdmount.sh
# copyright (c)2003 Nathan Clayton (nathanclayton@daftwazzock.com)
# This file is licensed under the GNU General Public License (GPL),
#  version 2.0 or higher.

# show the usage help
displayhelp() {
  echo "usbhdmount: mount or unmount the points on your USB harddrive"
  echo "SYNTAX: usbhdmount m|u deviceletter"
  echo "m                   mount the device"
  echo "u                   unmount the device"
  echo "usbdeviceletter     this is the device letter for your usb device"
  echo "                    (e.g. it would be \"a\" for /dev/sda, \"b\" for /dev/sdb, etc.)"
  exit 1
}

# check whether or not we're mounting or unmounting
mount_or_unmount() {
  case  "$1" in
    [mM] ) mountfiles "$2";;
    [uU] ) unmountfiles;;
    * ) displayhelp;;
  esac
}

#TODO: modify the commands according to your chosen mount points (the second number is part of the file ($1, and then another 1 could translate into a1 after variable substitution)
# recieves one argument, which letter to append to /dev/sd
mountfiles() {
  mount -t vfat /dev/sd$11 /mountlocation
  mount -t vfat /dev/sd$12 /mountlocation2
}

#TODO: modify the commands according to your chosen mount points
unmountfiles() {
  umount /mountlocation
  umount /mountlocation2
}

# check if there are two arguments, otherwise print out help text and exit
if [ "$#" -eq 2 ]
then
  mount_or_unmount "$1" "$2"
else
  echo "$#"
  displayhelp
fi
