#!/bin/bash

# check for number of arguments
if [ "$1" = "" ]
then
	echo "Usage: $0 <iso>"
	exit 1
fi

# ensure loopback module loaded
sudo modprobe loop 
if [ "$?" -ne 0 ]
then
	echo "Couldn't load module"
	exit
fi

# set iso and directory names
ISO=${1##*/}
DIR=${ISO%.*}

# mount iso
mkdir "$DIR"
sudo mount -t iso9660 -o loop "$1" "$DIR"

# pause
echo "$1 has been mounted at $DIR"
echo -e "\nPlease press Enter when finished to unmount the iso.\n"
read

# unmount iso and delete temporary folder
sudo umount "$DIR"
rmdir "$DIR"
exit
