Unifiy local config handling
authorChristian Hofstaedtler <ch@grml.org>
Mon, 5 Dec 2011 13:18:02 +0000 (14:18 +0100)
committerChristian Hofstaedtler <ch@grml.org>
Mon, 5 Dec 2011 14:12:09 +0000 (15:12 +0100)
Option -C works now as expected.

16 files changed:
etc/grml/fai/config/hooks/updatebase.GRMLBASE
etc/grml/fai/config/scripts/GRMLBASE/01-packages
etc/grml/fai/config/scripts/GRMLBASE/02-run
etc/grml/fai/config/scripts/GRMLBASE/03-get-sources
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/36-cpufrequtils
etc/grml/fai/config/scripts/GRMLBASE/37-portmap
etc/grml/fai/config/scripts/GRMLBASE/38-udev
etc/grml/fai/config/scripts/GRMLBASE/39-modprobe
etc/grml/fai/config/scripts/GRMLBASE/95-package-information
etc/grml/fai/config/scripts/GRMLBASE/96-apt-listbugs
grml-live

index 3a7b9af..7a79cbe 100755 (executable)
@@ -14,7 +14,7 @@ echo grml_chroot > $target/etc/debian_chroot
 
 HOSTNAME=''
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 echo "$HOSTNAME" > $target/etc/hostname
 
index b598516..5ad6aa9 100755 (executable)
@@ -10,7 +10,7 @@ set -u
 set -e
 
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 
 
 PACKAGE_LIST=/var/log/install_packages.list
index 6fab557..319a276 100755 (executable)
@@ -10,7 +10,7 @@ set -u
 set -e
 
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 
 # This is what initscripts would do if everything would be fine.
 if [ -L "$target/run" ] ; then
index 140faf1..fc7afb4 100755 (executable)
@@ -7,7 +7,7 @@
 ################################################################################
 
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 
 if ifclass SOURCES ; then
   echo "Class SOURCES set, retrieving source packages."
index 4751ecc..ce91001 100755 (executable)
@@ -11,7 +11,7 @@ set -e
 
 HOSTNAME=''
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 
 # the hostname of the chroot usually isn't the same as the one for the live-system
index b8a4198..be6d242 100755 (executable)
@@ -11,7 +11,7 @@ set -e
 
 USERNAME=''
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 [ -n "$USERNAME" ] || USERNAME=grml
 
 fcopy -v /etc/sudoers
index 375b52d..68f110b 100755 (executable)
@@ -11,7 +11,7 @@ set -e
 
 USERNAME=''
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 [ -n "$USERNAME" ] || USERNAME=grml
 
 if grep -q "$USERNAME:x:1000" $target/etc/group ; then
index 1585caf..fd52cf7 100755 (executable)
@@ -11,7 +11,7 @@ set -e
 
 USERNAME=''
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 [ -n "$USERNAME" ] || USERNAME=grml
 
 fcopy -v /etc/fstab
index d943534..0b02c35 100755 (executable)
@@ -11,7 +11,7 @@ set -e
 
 HOSTNAME=''
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 
 fcopy -v /etc/hosts
index 81a6367..16445d8 100755 (executable)
@@ -10,7 +10,7 @@ set -u
 set -e
 
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 
 if [ -r $target/usr/share/doc/cpufrequtils/examples/cpufrequtils.sample ] ; then
    if ! [ -r $target/etc/default/loadcpufreq ] ; then
index 16ef06a..fa84e56 100755 (executable)
@@ -10,7 +10,7 @@ set -u
 set -e
 
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 
 # Work around a bug in the portmap package, see
 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=317358
index 92bd257..33b677b 100755 (executable)
@@ -10,7 +10,7 @@ set -u
 set -e
 
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 
 CONFFILE="$target/etc/udev/rules.d/70-persistent-net.rules"
 STRING='This file was automatically generated by the /lib/udev/write_net_rules'
index a43c2d1..31e97f9 100755 (executable)
@@ -10,7 +10,7 @@ set -u
 set -e
 
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 
 # Make sure all modprobe configuration files use .conf as filename suffix.
 # See http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=module-init-tools;dist=unstable
index f9495fe..700abf7 100755 (executable)
@@ -11,7 +11,7 @@ set -e
 
 HOSTNAME=''
 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+[ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
 [ -n "$HOSTNAME" ] || HOSTNAME=grml
 PACKAGE_LOG=/var/log/fai/"$HOSTNAME"/last/
 
index 8049d7e..8a4bc3f 100755 (executable)
@@ -20,7 +20,7 @@ if ifclass RELEASE ; then
 set -u
   HOSTNAME=''
   [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
-  [ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+  [ -n "$GRML_LIVE_LOCAL_CONFIG" ] && . "$GRML_LIVE_LOCAL_CONFIG"
   [ -n "$HOSTNAME" ] || HOSTNAME=grml
 
   if [ -x $target/usr/sbin/apt-listbugs -a -x $target/usr/bin/apt-show-source ] && \
index 828acfa..1e8ddad 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -283,21 +283,6 @@ copy_addon_file() {
 }
 # }}}
 
-# read local (non-packaged) configuration {{{
-LOCAL_CONFIG=/etc/grml/grml-live.local
-if [ -r "$LOCAL_CONFIG" ] ; then
-   . $LOCAL_CONFIG
-else
-   LOCAL_CONFIG=''
-fi
-
-if [ -n "${GRML_LIVE_SOURCES:-}" ] ; then
-  eerror "Config variable \$GRML_LIVE_SOURCES is set. This variable has been deprecated."
-  ewarn  "Please set up \${GRML_FAI_CONFIG}/config/files/etc/apt/sources.list.d/* instead."
-  bailout 1
-fi
-# }}}
-
 # command line parsing {{{
 while getopts "a:C:c:d:D:g:i:I:o:r:s:t:T:U:v:AbBFnNquVz" opt; do
   case "$opt" in
@@ -306,7 +291,7 @@ while getopts "a:C:c:d:D:g:i:I:o:r:s:t:T:U:v:AbBFnNquVz" opt; do
     b) BUILD_ONLY=1 ;;
     B) BUILD_DIRTY=1 ;;
     c) CLASSES="$OPTARG" ;;
-    C) CONFIG="$OPTARG" ;;
+    C) GRML_LIVE_LOCAL_CONFIG="$OPTARG" ;;
     d) DATE="$OPTARG" ;;
     D) GRML_FAI_CONFIG="$OPTARG" ;;
     g) GRML_NAME="$OPTARG" ;;
@@ -332,6 +317,31 @@ done
 shift $(($OPTIND - 1))  # set ARGV to the first not parsed commandline parameter
 # }}}
 
+# read local (non-packaged) configuration {{{
+if [ -z "$GRML_LIVE_LOCAL_CONFIG" ]; then
+  if [ -r "/etc/grml/grml-live.local" ]; then
+    GRML_LIVE_LOCAL_CONFIG="/etc/grml/grml-live.local"
+  fi
+fi
+if [ -n "$GRML_LIVE_LOCAL_CONFIG" ]; then
+  if [ -r "$GRML_LIVE_LOCAL_CONFIG" ]; then
+    . $GRML_LIVE_LOCAL_CONFIG
+  else
+    eerror "Could not read specified local configuration file \"$GRML_LIVE_LOCAL_CONFIG\"."
+    bailout 1
+  fi
+  GRML_LIVE_LOCAL_CONFIG=$(readlink -f "$GRML_LIVE_LOCAL_CONFIG")
+else
+  GRML_LIVE_LOCAL_CONFIG=''
+fi
+
+if [ -n "${GRML_LIVE_SOURCES:-}" ] ; then
+  eerror "Config variable \$GRML_LIVE_SOURCES is set. This variable has been deprecated."
+  ewarn  "Please set up \${GRML_FAI_CONFIG}/config/files/etc/apt/sources.list.d/* instead."
+  bailout 1
+fi
+# }}}
+
 # assume sane defaults (if not set already) {{{
 [ -n "$ARCH" ]                    || ARCH="$(dpkg --print-architecture)"
 [ -n "$BOOT_METHOD" ]             || BOOT_METHOD='isolinux'
@@ -394,8 +404,7 @@ if [ -z "$FORCE" ] ; then
    echo "${PN} [${GRML_LIVE_VERSION}]: check your configuration (or use -F to force execution):"
    echo
    echo "  FAI classes:       $CLASSES"
-   [ -r "$LOCAL_CONFIG" ]        && echo "  Local config:      /etc/grml/grml-live.local"
-   [ -n "$CONFIG" ]              && echo "  Configuration:     $CONFIG"
+   [ -n "$GRML_LIVE_LOCAL_CONFIG" ] && echo "  Configuration:     $GRML_LIVE_LOCAL_CONFIG"
    [ -n "$GRML_FAI_CONFIG" ]     && echo "  Config directory:  $GRML_FAI_CONFIG"
    echo "  main directory:    $OUTPUT"
    [ -n "$UNPACK_CHROOT" ]       && echo "  Chroot from:       $UNPACK_CHROOT"
@@ -495,9 +504,7 @@ fi
 start_seconds=$(cut -d . -f 1 /proc/uptime)
 log "------------------------------------------------------------------------------"
 log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
-if [ -n "$LOCAL_CONFIG" ]; then
-  log "Using local config file: $LOCAL_CONFIG"
-fi
+log "Using local config file: $GRML_LIVE_LOCAL_CONFIG"
 log "Executed grml-live command line:"
 log "$CMDLINE"
 
@@ -539,7 +546,7 @@ case $SUITE in
 esac
 export SUITE # make sure it's available in FAI scripts
 
-for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" "$NFSROOT_CONF" ; do
+for file in "$LIVE_CONF" "$GRML_LIVE_LOCAL_CONFIG" "$NFSROOT_CONF" ; do
     if [ -n "$file" ] ; then
        sed "s|^FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file" | sponge "$file"
     fi
@@ -619,8 +626,8 @@ else
       echo force-unsafe-io > "$CHROOT_OUTPUT/etc/dpkg/dpkg.cfg.d/unsafe-io"
 
       log "Executed FAI command line:"
-      log "BUILD_ONLY=$BUILD_ONLY BOOTSTRAP_ONLY=$BOOTSTRAP_ONLY fai $VERBOSE -C $GRML_FAI_CONFIG -s file:///$GRML_FAI_CONFIG/config -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
-      BUILD_ONLY="$BUILD_ONLY" BOOTSTRAP_ONLY="$BOOTSTRAP_ONLY" fai $VERBOSE \
+      log "BUILD_ONLY=$BUILD_ONLY BOOTSTRAP_ONLY=$BOOTSTRAP_ONLY GRML_LIVE_LOCAL_CONFIG=$GRML_LIVE_LOCAL_CONFIG fai $VERBOSE -C $GRML_FAI_CONFIG -s file:///$GRML_FAI_CONFIG/config -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
+      BUILD_ONLY="$BUILD_ONLY" BOOTSTRAP_ONLY="$BOOTSTRAP_ONLY" GRML_LIVE_LOCAL_CONFIG="$GRML_LIVE_LOCAL_CONFIG" fai $VERBOSE \
                   -C "$GRML_FAI_CONFIG" -s "file:///$GRML_FAI_CONFIG/config" -c"$CLASSES" \
                   -u "$HOSTNAME" "$FAI_ACTION" "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
       RC="$PIPESTATUS" # notice: bash-only