Skip to content

Instantly share code, notes, and snippets.

@Oshuma
Created October 26, 2010 06:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oshuma/646418 to your computer and use it in GitHub Desktop.
Save Oshuma/646418 to your computer and use it in GitHub Desktop.
function mount_iso() {
local iso_file
local mnt_directory
local opt
while getopts f:d:h opt; do
case $opt in
(h)
print "Options:"
print " -f <file.iso>"
print " -d </path/to/mnt>"
return 1
;;
(f)
iso_file=$OPTARG
;;
(d)
mnt_directory=$OPTARG
;;
(?)
$0 -h
return 1
;;
esac
done
if [[ -z $iso_file ]] || [[ -z $mnt_directory ]]; then
print Missing required option.
$0 -h
return 1
fi
if [[ $UID != "0" ]]; then
local use_sudo="sudo"
fi
$use_sudo mkdir -p $mnt_directory &&
$use_sudo mount -t iso9660 -o loop $iso_file $mnt_directory
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment