+ Examples:
+ $0 -s http://192.168.23.42:8000/grml/ -o small.iso grml64_2010.12.iso
+
+ Will generate a file small.iso which tries to download the squashfs file from
+ http://192.168.23.42:8000/grml/ - the squashfs file is placed in the same
+ output directory as the ISO file.
+"
+ [ -n "$1" ] && exit $1 || exit 1
+ }
+# }}}
+
+# command line handling {{{
+ [[ $# -gt 2 ]] || usage 1
+
+ ISOFILE=''
+ DIR=''
+ ADD_OPTS=''
+ FORCE=''
+ URI=''
+ typeset -a GRML2USB_OPTS
+ while getopts fb:c:o:r:p:s:t: name; do
+ case $name in
+ o) ISOFILE="$OPTARG";;
+ b) GRML2USB_OPTS+=(--bootoptions="$OPTARG");;
+ c) DIR="$(readlink -f "$OPTARG")"; [ -n "$DIR" ] || { echo "Could not read $OPTARG - exiting" >&2 ; exit 1 ; } ;;
+ f) FORCE='true';;
+ r) GRML2USB_OPTS+=(--remove-bootoption="$OPTARG");;
+ p) GRML2USB_OPTS+=("$OPTARG");;
+ s) URI="$OPTARG";;
+ t) WRKDIR="$(readlink -f "$OPTARG")";;
+ ?) usage 2;;
+ esac
+ done
+
+ # test for specified URI
+ if [ -n "$URI" ] ; then
+ GRML2USB_OPTS+=(--bootoptions="fetch=$URI")
+ fi
+
+ if [ -n "$WRKDIR" ] ; then
+ GRML2USB_OPTS+=(--tmpdir="$WRKDIR")
+ fi
+
+# make sure -o is specified
+ [ -n "$ISOFILE" ] || usage 1
+
+# we don't to override any files by accident
+ if [ -e "$ISOFILE" -a ! -n "$FORCE" ]; then
+ echo "Error: target file $ISOFILE exists already." >&2
+ exit 1
+ fi
+
+ if [ ! -z "$DIR" -a ! -d "$DIR" ] ; then
+ echo "Error: specified parameter for -c is not a directory" >&2
+ exit 1
+ fi
+# }}}
+
+# we need root permissions for executing grml2usb {{{
+ if [[ $(id -u) != 0 ]]; then
+ echo >&2 "Error: please run $0 as root."
+ exit 1
+ fi
+# }}}
+
+# check for grml2usb {{{
+ if [ ! -x "$(which $GRML2USB)" ] && [ ! -x "$GRML2USB" ] ; then
+ echo "Error: Could not find grml2usb executable. Is /usr/sbin missing in PATH?" >&2
+ echo "Tip: run GRML2USB=/usr/sbin/grml2usb grml2iso ... as workaround" >&2
+ if [ -x "./$GRML2USB" ] ; then
+ echo >&2 "If you executed grml2iso from the grml2usb repository use"
+ echo >&2 "GRML2USB=./grml2usb $0 $*"
+ fi
+ exit 1
+ fi
+# }}}