X-Git-Url: http://www.club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?p=cmccabe-bin;a=blobdiff_plain;f=nero.sh;fp=nero.sh;h=a23cab5d572a46f32b92ec23a4cb215e4cf4ff5c;hp=0000000000000000000000000000000000000000;hb=2e66020a9ca5261c67858f7378f39684827bc7ca;hpb=37227cd97b103c102365830ef122f08013daf60a diff --git a/nero.sh b/nero.sh new file mode 100755 index 0000000..a23cab5 --- /dev/null +++ b/nero.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +die() { + echo $@ + exit 1 +} + +my_uname=$(uname -a) +case "${my_uname}" in + Darwin*) ;; + *)die "This script only works on MacOS" +esac + +usage() { + cat <<EOF +nero.sh: CD-R burning tool for MacOS. + +-d [directory] Create a data CD using the given directory +-k Skip cleanup +-h Show this help message +EOF +} + +data_dir="" +skip_cleanup=0 +while getopts "d:kh" flag; do + case $flag in + d) data_dir="${OPTARG}";; + k) skip_cleanup=1;; + h) usage; exit 0;; + *) usage; exit 1;; + esac +done +shift $OPTIND +[[ $# -ne 0 ]] || die "unknown arguments at end. -h for help." + +if [[ $data_dir != "" ]]; then + temp_dir="`mktemp -d`" + echo "== created temporary directory $temp_dir" + if [[ $skip_cleanup == 1 ]]; then + echo "== will not install cleanup hook" + else + function remove_iso_temp { + echo "== removing $temp_dir" + rm -rf -- "${temp_dir}" + } + trap remove_iso_temp EXIT + fi + echo "== creating ${temp_dir}/iso" + hdiutil makehybrid -iso -joliet -o "${temp_dir}/temp" "${data_dir}" + echo "== burning ${temp_dir}/temp.iso" + hdiutil burn "${temp_dir}/temp.iso" +else + die "You must supply a path. -h for help." +fi