add TODO file, new script 03_grml-live-chroot.sh and grml-all packages listing
[grml-live.git] / scripts / grml-live
index ee7fbdd..1d693cd 100755 (executable)
@@ -4,26 +4,82 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Thu Feb 08 22:35:43 CET 2007
+# Latest change: Tue Feb 13 00:16:11 CET 2007
 ################################################################################
 
-LANG=C
-LC_ALL=C
-
-DEBUG=1        # be more verbose on stdout?
-DEBUG_SYSLOG=1 # log actions to syslog?
+LANG=C ; LC_ALL=C
+set -e # fail on any error
 
 # functions
-FUNCTIONSFILE='functions.sh'
-
+FUNCTIONSFILE='functions.sh' # TODO: fix location
 for file in $FUNCTIONSFILE /etc/grml/lsb-functions  /etc/grml/script-functions ; do
-    [[ -r $FUNCTIONSFILE ]] && source $file || { print "Reading $file failed, fatal error, exiting." ; exit 1 }
+    [ -r "$file" ] && source "$file" || { print "Reading $file failed. Fatal error, exiting." ; exit 1 }
 done
 
+# Clean exit
 trap bailout 1 2 3 15
 
-# main execution
-debug "executing cmdline_options" ; cmdline_options
+# We need root permissions to execute all the chroot stuff
+check4root || bailout 1
+
+# default variables
+[ -n "$DEBOOTSTRAP" ] || DEBOOTSTRAP='debootstrap'
+[ -n "$ARCH" ]        || ARCH="$(dpkg --print-architecture)"
+[ -n "$RELEASE" ]     || RELEASE='sid'
+[ -n "$MIRROR" ]      || MIRROR='ftp://ftp.tugraz.at/mirror/debian'
+[ -n "$TARGET" ]      || TARGET="$(pwd)/grml-live/chroot/"
+
+# cmdline parsing, allow overwriting of variables
+while true ; do
+   case "${1}" in
+        (-c|--config) CONFIG="${2}"
+                shift 2 ;;
+        (-r|--root) TARGET="${2}"
+                shift 2 ;;
+        (-h|--hook) HOOK="${2}"
+                shift 2 ;;
+        (-v|--version) usage
+                exit 1 ;;
+        (--) shift
+                break ;;
+        (*) break ;;
+   esac
+done
+
+# configuration file
+if [ -n "$CONFIG" ] ; then
+   [ -r "$CONFIG" ] || bailout 1 "Sorry, configuration file $CONFIG could not be read. Fatal error, exiting"
+   debug "sourcing $CONFIG"
+   source "$CONFIG"
+else
+   source ../config/grml-live.conf # TODO: fix location
+fi
+
+# make sure we have some variables, directories,... available before main execution
+[ -d "$TARGET" ] || mkdir "$TARGET"
+[ -n "$ARCH" ] && ARCH="$DEB_HOST_ARCH" || bailout 1 "\$ARCH not set, exiting."
+
+# TODO: fix location
+source 01_bootstrap.sh
+source 02_chroot.sh
+
+if [ -n "$HOOK" ] ; then
+   debug "executing given hook $HOOK"
+   $HOOK
+   exit 0
+fi
+
+## main execution
+
+# 01_bootstrap.sh
+bootstrap
+
+# 02_chroot.sh
+patch_chroot apply
+chroot_live_prepare
+chroot_live_execute
+chroot_shell
+patch_chroot deapply
 
 ## END OF FILE #################################################################
 # vim: ai tw=80 ft=zsh expandtab