From 9dafaad2fe959f195d68a38655f60d00ee028256 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 5 Dec 2011 14:18:02 +0100 Subject: [PATCH] Unifiy local config handling Option -C works now as expected. --- etc/grml/fai/config/hooks/updatebase.GRMLBASE | 2 +- etc/grml/fai/config/scripts/GRMLBASE/01-packages | 2 +- etc/grml/fai/config/scripts/GRMLBASE/02-run | 2 +- .../fai/config/scripts/GRMLBASE/03-get-sources | 2 +- etc/grml/fai/config/scripts/GRMLBASE/05-hostname | 2 +- etc/grml/fai/config/scripts/GRMLBASE/20-sudo | 2 +- etc/grml/fai/config/scripts/GRMLBASE/21-usersetup | 2 +- etc/grml/fai/config/scripts/GRMLBASE/30-fstab | 2 +- etc/grml/fai/config/scripts/GRMLBASE/34-hosts | 2 +- .../fai/config/scripts/GRMLBASE/36-cpufrequtils | 2 +- etc/grml/fai/config/scripts/GRMLBASE/37-portmap | 2 +- etc/grml/fai/config/scripts/GRMLBASE/38-udev | 2 +- etc/grml/fai/config/scripts/GRMLBASE/39-modprobe | 2 +- .../config/scripts/GRMLBASE/95-package-information | 2 +- .../fai/config/scripts/GRMLBASE/96-apt-listbugs | 2 +- grml-live | 55 ++++++++++++---------- 16 files changed, 46 insertions(+), 39 deletions(-) diff --git a/etc/grml/fai/config/hooks/updatebase.GRMLBASE b/etc/grml/fai/config/hooks/updatebase.GRMLBASE index 3a7b9af..7a79cbe 100755 --- a/etc/grml/fai/config/hooks/updatebase.GRMLBASE +++ b/etc/grml/fai/config/hooks/updatebase.GRMLBASE @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/01-packages b/etc/grml/fai/config/scripts/GRMLBASE/01-packages index b598516..5ad6aa9 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/01-packages +++ b/etc/grml/fai/config/scripts/GRMLBASE/01-packages @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/02-run b/etc/grml/fai/config/scripts/GRMLBASE/02-run index 6fab557..319a276 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/02-run +++ b/etc/grml/fai/config/scripts/GRMLBASE/02-run @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources b/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources index 140faf1..fc7afb4 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources +++ b/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources @@ -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." diff --git a/etc/grml/fai/config/scripts/GRMLBASE/05-hostname b/etc/grml/fai/config/scripts/GRMLBASE/05-hostname index 4751ecc..ce91001 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/05-hostname +++ b/etc/grml/fai/config/scripts/GRMLBASE/05-hostname @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/20-sudo b/etc/grml/fai/config/scripts/GRMLBASE/20-sudo index b8a4198..be6d242 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/20-sudo +++ b/etc/grml/fai/config/scripts/GRMLBASE/20-sudo @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup b/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup index 375b52d..68f110b 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup +++ b/etc/grml/fai/config/scripts/GRMLBASE/21-usersetup @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/30-fstab b/etc/grml/fai/config/scripts/GRMLBASE/30-fstab index 1585caf..fd52cf7 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/30-fstab +++ b/etc/grml/fai/config/scripts/GRMLBASE/30-fstab @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/34-hosts b/etc/grml/fai/config/scripts/GRMLBASE/34-hosts index d943534..0b02c35 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/34-hosts +++ b/etc/grml/fai/config/scripts/GRMLBASE/34-hosts @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/36-cpufrequtils b/etc/grml/fai/config/scripts/GRMLBASE/36-cpufrequtils index 81a6367..16445d8 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/36-cpufrequtils +++ b/etc/grml/fai/config/scripts/GRMLBASE/36-cpufrequtils @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/37-portmap b/etc/grml/fai/config/scripts/GRMLBASE/37-portmap index 16ef06a..fa84e56 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/37-portmap +++ b/etc/grml/fai/config/scripts/GRMLBASE/37-portmap @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/38-udev b/etc/grml/fai/config/scripts/GRMLBASE/38-udev index 92bd257..33b677b 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/38-udev +++ b/etc/grml/fai/config/scripts/GRMLBASE/38-udev @@ -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' diff --git a/etc/grml/fai/config/scripts/GRMLBASE/39-modprobe b/etc/grml/fai/config/scripts/GRMLBASE/39-modprobe index a43c2d1..31e97f9 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/39-modprobe +++ b/etc/grml/fai/config/scripts/GRMLBASE/39-modprobe @@ -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 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/95-package-information b/etc/grml/fai/config/scripts/GRMLBASE/95-package-information index f9495fe..700abf7 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/95-package-information +++ b/etc/grml/fai/config/scripts/GRMLBASE/95-package-information @@ -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/ diff --git a/etc/grml/fai/config/scripts/GRMLBASE/96-apt-listbugs b/etc/grml/fai/config/scripts/GRMLBASE/96-apt-listbugs index 8049d7e..8a4bc3f 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/96-apt-listbugs +++ b/etc/grml/fai/config/scripts/GRMLBASE/96-apt-listbugs @@ -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 ] && \ diff --git a/grml-live b/grml-live index 828acfa..1e8ddad 100755 --- 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 -- 2.1.4