+# == business-logic of command line parameter-processing
+
+# source configuration file in <confdir> if supplied. {{{
+[ "$_opt_confdir" ] && {
+ CONFFILES=$_opt_confdir
+ einfo "Using config files under $CONFFILES/."
+ if ! [ -r "$CONFFILES/config" ] ; then
+ eerror "Error: config file $CONFFILES/config not found."; eend 1; exit 1
+ fi
+ if ! . "$CONFFILES/config" ; then
+ eerror "Error reading config file $CONFFILES/config" ; eend 1 ; exit 1
+ fi
+ # restore the command line parameter value
+ CONFFILES=$_opt_confdir
+}
+# }}}
+
+[ "$_opt_mirror" ] && MIRROR=$_opt_mirror
+[ "$_opt_iso" ] && ISO=$_opt_iso
+[ "$_opt_release" ] && RELEASE=$_opt_release
+[ "$_opt_target" ] && TARGET=$_opt_target
+[ "$_opt_vmfile" ] && VIRTUAL=1
+[ "$_opt_vmsize" ] && VMSIZE=$_opt_vmsize
+[ "$_opt_mntpoint" ] && MNTPOINT=$_opt_mntpoint
+[ "$_opt_debopt" ] && DEBOOTSTRAP_OPT=$_opt_debopt
+[ "$_opt_interactive" ] && INTERACTIVE=1
+[ "$_opt_config" ] && CONFIGFILE=$_opt_config
+[ "$_opt_filesystem" ] && MKFS="mkfs.$_opt_filesystem"
+[ "$_opt_packages_set" ] && PACKAGES='yes'
+[ "$_opt_nopackages" ] && PACKAGES=''
+[ "$_opt_debconf_set" ] && DEBCONF='yes'
+[ "$_opt_scripts_set" ] && SCRIPTS='yes'
+[ "$_opt_pre_scripts_set" ] && PRE_SCRIPTS='yes'
+[ "$_opt_chroot_scripts_set" ] && CHROOT_SCRIPTS='yes'
+[ "$_opt_keep_src_list" ] && KEEP_SRC_LIST='yes'
+[ "$_opt_grmlrepos" ] && GRMLREPOS='yes'
+[ "$_opt_hostname" ] && HOSTNAME=$_opt_hostname
+[ "$_opt_password" ] && ROOTPASSWORD=$_opt_password
+[ "$_opt_nopassword" ] && NOPASSWORD='yes'
+[ "$_opt_bootappend" ] && BOOT_APPEND=$_opt_bootappend
+[ "$_opt_grub" ] && GRUB=$_opt_grub
+[ "$_opt_arch" ] && ARCH=$_opt_arch
+[ "$_opt_insecure" ] && SECURE='false'
+[ "$_opt_force" ] && FORCE=$_opt_force
+[ "$_opt_verbose" ] && VERBOSE="-v"
+
+[ "$_opt_help" ] && {
+ usage ; eend 0
+ eend 0
+ exit 0
+}
+
+[ "$_opt_version" ] && {
+ einfo "$PN - version $VERSION"
+ einfo "Send bug reports to bugs@grml.org or http://grml.org/bugs/"
+ eend 0
+ exit 0
+}
+# }}}
+
+# check for root permissions {{{
+if ! check4root ; then
+ echo "For usage instructions please execute '$PN --help'."
+ exit 1
+fi
+# }}}
+
+# make sure we have what we need {{{
+if [ -n "$VIRTUAL" ] ; then
+ check4progs kpartx mksh qemu-img || exit 1
+fi
+# }}}
+
+# source specified configuration file {{{
+if [ -n "$CONFIGFILE" ] ; then
+ einfo "Reading specified config file $CONFIGFILE."
+ if ! . "$CONFIGFILE" ; then
+ eerror "Error reading config file $CONFIGFILE" ; eend 1 ; exit 1
+ fi
+fi
+# }}}
+
+# backwards compability checks {{{
+if [ -n "$GROOT" ] ; then
+ eerror "Error: you seem to have \$GROOT configured."
+ eerror "This variable is no longer supported, please visit the"
+ eerror "grml-debootstrap documentation for details."
+ eend 1
+ exit 1
+fi
+
+if echo "$GRUB" | grep -q '^hd' ; then
+ eerror "Error: this syntax for the grub configuration variable is no longer supported."
+ eerror "Please do not use hd... any longer but /dev/sdX instead."
+ eend 1
+ exit 1
+fi