+# The defaults to be modified from cmdline
+di_cd=
+# look here for more details about the default IP of the host:
+# # http://www.virtualbox.org/manual/ch09.html#changenat
+mirror_host=10.0.0.1:9999
+di_tz='US/Eastern'
+di_preseed_in=
+
+function usage {
+echo "Usage: $0 [OPTIONS]
+
+Create ND VirtualBox appliance.
+
+Options:
+ -p PRESEED_IN path to preesed.cfg.in file for d-i
+ -i ISO path to debian installation iso file
+ -m MIRROR debian mirror to use for installation
+ -t TIME_ZONE time zone of virtual machine
+ -h Show this help and exit
+"
+}
+
+# Process cmdline
+while getopts "p:i:" OPTION
+do
+ case $OPTION in
+ "p") di_preseed_in="$OPTARG";;
+ "i") di_cd="$OPTARG";;
+ "m") mirror_host="$OPTARG";;
+ "t") di_tz="$OPTARG";;
+ "h") exit 1;;
+ esac
+done
+
+if [ -z "$di_cd" ] ; then
+ echo "You must specify the iso image (-i)" >&2
+ exit 1
+fi
+
+if [ -z "$di_preseed_in" ]; then
+ # deduce release and use corresponding directory here
+ release=$(basename "$di_cd" | cut -d- -f2)
+ di_preseed_in=$(dirname $0)/../d-i/$release/preseed.cfg.in
+ if [ ! -e "$di_preseed_in" ]; then
+ echo "$di_preseed_in is not found. Specify one with -p" >&2
+ exit 2
+ fi
+fi
+
+# Figure out our IP address for VM to reach webserver
+eth=`route | awk '/default/{print $8;}'`
+di_host=`ip addr show dev $eth | sed -ne '/inet /s, *inet \([0-9.]*\)/.*,\1,gp'`