Add initial support for option -C
authorMichael Prokop <devnull@localhost>
Sun, 25 Nov 2007 17:37:22 +0000 (18:37 +0100)
committerMichael Prokop <devnull@localhost>
Sun, 25 Nov 2007 17:37:22 +0000 (18:37 +0100)
debian/changelog
docs/grml-live.txt
etc/grml/fai/config/hooks/instsoft.GRMLBASE
etc/grml/fai/config/scripts/GRMLBASE/05-hostname
etc/grml/fai/config/scripts/GRMLBASE/20-sudo
etc/grml/fai/config/scripts/GRMLBASE/21-usersetup
etc/grml/fai/config/scripts/GRMLBASE/30-fstab
etc/grml/fai/config/scripts/GRMLBASE/34-hosts
etc/grml/fai/config/scripts/GRMLBASE/95-package-information
etc/grml/fai/config/scripts/GRMLBASE/96-apt-listbugs
grml-live

index b9cf26f..bcf7eba 100644 (file)
@@ -10,6 +10,9 @@ grml-live (0.0.10) unstable; urgency=low
   * Log the executed FAI command line to /var/log/grml-live.log.
   * No longer update chroot system via instsoft.GRMLBASE as FAI
     should do that now.
+  * New option '-C <configuration_file>' for specifying a configuration
+    file. Needs heavy testing though, because the files are updated
+    during runtime it isn't as easy as expected to be. :-/
   * Do not enable apt-listbugs if the binary is not available.
     [Testing: issue340]
   * Add keychain package to GRML_MEDIUM.
index b36947d..c4749fe 100644 (file)
@@ -17,7 +17,7 @@ grml-live [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] [-i <iso_name> ]
 *******************************************************************************
 Important! This document is growing as requested. If you have questions which
 aren't answered by this document yet please let me know: <mika@grml.org>!
-This document currently applies to grml-live version 0.0.6.
+This document currently applies to grml-live version 0.0.10.
 *******************************************************************************
 
 Description
@@ -72,6 +72,22 @@ can specify a class providing a grml-kernel (see
 /etc/grml/fai/config/package_config/ for a full list).  So instead of GRML_SMALL
 you can also use GRML_MEDIUM and GRML_FULL instead.
 
+  -C **CONFIGURATION_FILE**::
+
+The specified file is used as configuration file for grml-live. By default
+/etc/grml/grml-live.conf is used for main configuration. If a file named
+/etc/grml/grml-live.local exists it is used as well (sourced after reading
+/etc/grml/grml-live.conf to allow overriding settings). As a last option the
+specified configuration file is sourced so it is possible to override settings
+of /etc/grml/grml-live.conf as well as of /etc/grml/grml-live.local. Please
+notice that all configuration files have to be adjusted during execution of
+grml-live, so please make sure you use /etc/grml/grml-live.conf as a base for
+your own configuration file. Please also notice that the configuration file
+specified via this option is **not** (yet) supported inside the
+scripts/hooks/classes at /etc/grml/fai/config. Instead use
+/etc/grml/grml-live.conf and/or /etc/grml/grml-live.local for configuration
+stuff used inside /etc/grml/fai/config.
+
   -F::
 
 Force execution and do not prompt for acknowledgment of configuration.
@@ -107,7 +123,7 @@ Specify the Debian suite you want to use for your live-system.  Defaults to
 
   -t **TEMPLATE_DIRECTORY**::
 
-Specify place of the templates used for building the ISO. By default 
+Specify place of the templates used for building the ISO. By default
 (and if not manually specified) this is /usr/share/grml-live/templates/.
 
   -u::
@@ -336,7 +352,7 @@ FAQ
 Help, I'm using Debian etch and I don't have FAI version >3.2
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-  wget http://www.informatik.uni-koeln.de/fai/download/etch/fai-client_3.2.3_all.deb \ 
+  wget http://www.informatik.uni-koeln.de/fai/download/etch/fai-client_3.2.3_all.deb \
        http://www.informatik.uni-koeln.de/fai/download/etch/fai-server_3.2.3_all.deb \
        http://www.informatik.uni-koeln.de/fai/download/etch/fai-doc_3.2.3_all.deb
   dpkg -i fai-client_3.2.3_all.deb fai-server_3.2.3_all.deb fai-doc_3.2.3_all.deb
index def9e17..4d087e7 100755 (executable)
@@ -4,7 +4,7 @@
 # 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 or any later version.
-# Latest change: Mon Nov 12 11:14:32 CET 2007 [mika]
+# Latest change: Sun Nov 25 18:28:54 CET 2007 [mika]
 ################################################################################
 
 set -u
@@ -14,7 +14,8 @@ set -e
 echo grml_chroot > $target/etc/debian_chroot
 
 HOSTNAME=''
-[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 echo "$HOSTNAME" > $target/etc/hostname
 
index 63b9b8e..ee5ba49 100755 (executable)
@@ -11,7 +11,8 @@ set -u
 set -e
 
 HOSTNAME=''
-[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 echo "$HOSTNAME" > $target/etc/hostname
 
index c550c5f..eb70e40 100755 (executable)
@@ -11,7 +11,8 @@ set -u
 set -e
 
 USERNAME=''
-[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
 [ -n "$USERNAME" ] || USERNAME=grml
 
 if [ -r /etc/grml/fai/files/etc/sudoers ] ; then
index a94fc7b..3214511 100755 (executable)
@@ -11,7 +11,8 @@ set -u
 set -e
 
 USERNAME=''
-[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
 [ -n "$USERNAME" ] || USERNAME=grml
 
 if grep -q "$USERNAME:x:1000" $target/etc/group ; then
index eb3f192..80f58d9 100755 (executable)
@@ -11,7 +11,8 @@ set -u
 set -e
 
 USERNAME=''
-[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
 [ -n "$USERNAME" ] || USERNAME=grml
 
 if [ -r /etc/grml/fai/files/etc/fstab ] ; then
index 1363b95..5ee9c76 100755 (executable)
@@ -11,7 +11,8 @@ set -u
 set -e
 
 HOSTNAME=''
-[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 
 if [ -r /etc/grml/fai/files/etc/hosts ] ; then
index e6d82f8..9a9fd84 100755 (executable)
@@ -8,7 +8,8 @@
 ################################################################################
 
 HOSTNAME=''
-[ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 
 if ! [ -d /var/log/fai/"$HOSTNAME"/last/ ] ; then
index a6ed5a9..a8b4a38 100755 (executable)
@@ -29,7 +29,8 @@ fi
 if ifclass RELEASE ; then
 
   HOSTNAME=''
-  [ -r /etc/grml/grml-live.conf ] && . /etc/grml/grml-live.conf
+  [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+  [ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
   [ -n "$HOSTNAME" ] || HOSTNAME=grml
 
   if [ -r /etc/resolv.conf ] ; then
index a8f5eaa..a25265a 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -4,7 +4,7 @@
 # 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 or any later version.
-# Latest change: Sun Nov 25 17:16:07 CET 2007 [mika]
+# Latest change: Sun Nov 25 18:29:07 CET 2007 [mika]
 ################################################################################
 
 # read configuration files, set some misc variables {{{
@@ -95,6 +95,14 @@ if [ -n "$ZERO_LOGFILE" ] ; then
    echo -n > $LOGFILE
 fi
 
+if [ -n "$ZERO_FAI_LOGFILE" ] ; then
+   if [ -d /var/log/fai/"$HOSTNAME" ] ; then
+      rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink last)"
+      rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink last-softupdate)"
+      rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink last-dirinstall)"
+   fi
+fi
+
 NFSROOT_CONF=/etc/grml/fai/make-fai-nfsroot.conf
 
 # }}}
@@ -179,10 +187,11 @@ http://grml.org/bugs/
 
 # command line parsing {{{
 
-while getopts "a:c:g:i:o:r:s:t:v:FhuV" opt; do
+while getopts "a:C:c:g:i:o:r:s:t:v:FhuV" opt; do
   case "$opt" in
     a) ARCH="$OPTARG" ;;
     c) CLASSES="$OPTARG" ;;
+    C) CONFIG="$OPTARG" ;;
     g) GRML_NAME="$OPTARG" ;;
     i) ISO_NAME="$OPTARG" ;;
     o) OUTPUT="$OPTARG"
@@ -218,6 +227,7 @@ if [ -z "$FORCE" ] ; then
    echo
    echo "  FAI classes:       $CLASSES"
    echo "  main directory:    $OUTPUT"
+   [ -n "$CONFIG" ]        && echo "  configuration:     $CONFIG"
    [ -n "$CHROOT_OUTPUT" ] && echo "  chroot target:     $CHROOT_OUTPUT"
    [ -n "$BUILD_OUTPUT" ]  && echo "  build target:      $BUILD_OUTPUT"
    [ -n "$ISO_OUTPUT" ]    && echo "  ISO target:        $ISO_OUTPUT"
@@ -241,6 +251,26 @@ if [ -z "$FORCE" ] ; then
    echo
 fi
 
+# read local (non-packaged) configuration:
+LOCAL_CONFIG=/etc/grml/grml-live.local
+if [ -r "$LOCAL_CONFIG" ] ; then
+   log "Sourcing $LOCAL_CONFIG"
+   . $LOCAL_CONFIG
+else
+   LOCAL_CONFIG=''
+fi
+
+if [ -n "$CONFIG" ] ; then
+   if ! [ -f "$CONFIG" ] ; then
+      log "Sorry, $CONFIG could not be read. Exiting. [$(date)]"
+      eerror "Sorry, $CONFIG could not be read. Exiting."
+      bailout 1
+   else
+      log "Sourcing $CONFIG"
+      . $CONFIG
+   fi
+fi
+
 start_seconds=$(cut -d . -f 1 /proc/uptime)
 log "------------------------------------------------------------------------------"
 log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
@@ -271,10 +301,15 @@ fi
 
 # does this suck? YES!
 if [ -n "$SUITE" ] ; then
-   sed -i "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF
 
-   DIST="\|\ etch\ \|\ stable\ \|\ lenny\ \|\ testing\ \|\ sid\ \|\ unstable\ "
-   sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" $LIVE_CONF
+   for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
+       if [ -n "$file" ] ; then
+          sed -i "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF
+          DIST="\|\ etch\ \|\ stable\ \|\ lenny\ \|\ testing\ \|\ sid\ \|\ unstable\ "
+          sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" $file
+       fi
+   done
+
    sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list
    # notice: activate grml-live pool only if we are building against unstable:
    if grep -qe unstable -qe sid /etc/grml/fai/apt/sources.list ; then
@@ -286,7 +321,11 @@ if [ -n "$SUITE" ] ; then
       sed -i 's/.*grml-live.*/# removed grml-live repository/' /etc/grml/fai/apt/sources.list
    fi
 
-   sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" $LIVE_CONF
+   for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
+       if [ -n "$file" ] ; then
+          sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file"
+       fi
+   done
    sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" $NFSROOT_CONF
 fi