Rename mtube.sh to tube, use yt-dlp
[cmccabe-bin] / nero.sh
1 #!/usr/bin/env bash
2
3 die() {
4     echo $@
5     exit 1
6 }
7
8 my_uname=$(uname -a)
9 case "${my_uname}" in
10     Darwin*) ;;
11     *)die "This script only works on MacOS"
12 esac
13
14 usage() {
15     cat <<EOF
16 nero.sh: CD-R burning tool for MacOS.
17
18 -d [directory]      Create a data CD using the given directory
19 -k                  Skip cleanup
20 -h                  Show this help message
21 EOF
22 }
23
24 data_dir=""
25 skip_cleanup=0
26 while getopts "d:kh" flag; do
27     case $flag in
28         d) data_dir="${OPTARG}";;
29         k) skip_cleanup=1;;
30         h) usage; exit 0;;
31         *) usage; exit 1;;
32     esac
33 done
34 shift $OPTIND
35 [[ $# -ne 0 ]] || die "unknown arguments at end. -h for help."
36
37 if [[ $data_dir != "" ]]; then
38     temp_dir="`mktemp -d`"
39     echo "== created temporary directory $temp_dir"
40     if [[ $skip_cleanup == 1 ]]; then
41         echo "== will not install cleanup hook"
42     else
43         function remove_iso_temp {
44             echo "== removing $temp_dir"
45             rm -rf -- "${temp_dir}"
46         }
47         trap remove_iso_temp EXIT
48     fi
49     echo "== creating ${temp_dir}/iso"
50     hdiutil makehybrid -iso -joliet -o "${temp_dir}/temp" "${data_dir}"
51     echo "== burning ${temp_dir}/temp.iso"
52     hdiutil burn "${temp_dir}/temp.iso"
53 else
54     die "You must supply a path. -h for help."
55 fi