Skip to content

Instantly share code, notes, and snippets.

@jodoherty
Created December 17, 2015 17:19
Show Gist options
  • Save jodoherty/5d270cb026c647612eb0 to your computer and use it in GitHub Desktop.
Save jodoherty/5d270cb026c647612eb0 to your computer and use it in GitHub Desktop.
burndvd script
#!/bin/sh
#
# burndvd 0.1
#
# Copyright (c) 2015 James O'Doherty <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Requires growisofs and mkisofs.
#
dryrun=false
output=
input=
while [ $# -gt 0 ]; do
case $1 in
-o)
if [ "$output" != "" ]; then
echo Please specify only one output file
exit 1
fi
output="$2"
shift;;
--dry)
dryrun=true;;
*)
if [ "$input" != "" ]; then
echo Please specify only one input directory
exit 1
fi
input="$1";;
esac
shift
done
if [ "$output" == "" ]; then
output=/dev/dvd
fi
if [ "$input" == "" ]; then
echo Please specify an input directory or ISO
exit 1
fi
case "$input" in
*.[iI][sS][oO])
if ! [ -f "$input" ]; then
echo Error: Expected ISO file
exit 1
fi
OPTIONS=
case "$output" in
/dev/*)
CMD="growisofs -dvd-compat"
CMD="$CMD -use-the-force-luke=dao"
CMD="$CMD -Z"
OUT="$output=$input"
input=
;;
*)
echo iso file output must be a device
exit 1
;;
esac
;;
*)
if ! [ -d "$input" ]; then
echo Error: Expected directory
exit 1
fi
OPTIONS="-J -r -file-mode 666 -joliet-long -iso-level 4"
case "$output" in
/dev/*)
CMD="growisofs -dvd-compat"
CMD="$CMD -use-the-force-luke=dao"
CMD="$CMD -Z"
OUT="$output"
;;
*)
CMD="mkisofs -o"
OUT="$output"
;;
esac
;;
esac
echo Executing $CMD "$OUT" $OPTIONS $input
if $dryrun; then
exit 0
fi
$CMD "$OUT" $OPTIONS $input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment