Created
October 26, 2010 06:13
-
-
Save Oshuma/646418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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