add autoconfig parameter to change GRMLCFG label [Closes: issue673]
authorMartin Scharm <martin@binfalse.de>
Sat, 12 Mar 2011 11:58:44 +0000 (12:58 +0100)
committerUlrich Dangel <mru@grml.org>
Sat, 12 Mar 2011 12:25:09 +0000 (13:25 +0100)
autoconfig.functions
doc/grml-autoconfig.current.txt
tests/test_grmlcfg.sh [new file with mode: 0755]

index 0bf61e4..87117db 100755 (executable)
@@ -1791,8 +1791,11 @@ config_finddcsdir() {
 #    foo, even if a GRMLCFG partition is present.
 DCSDIR=""
 DCSMP="/mnt/grml"
 #    foo, even if a GRMLCFG partition is present.
 DCSDIR=""
 DCSMP="/mnt/grml"
+# autoconfig, see issue673
+GRMLCFG="$(getbootparam 'autoconfig' 2>>$DEBUG)"
+[ -n "$GRMLCFG" ] || GRMLCFG="GRMLCFG"
 if checkbootparam 'noautoconfig' || checkbootparam 'forensic' ; then
 if checkbootparam 'noautoconfig' || checkbootparam 'forensic' ; then
-  ewarn "Skipping running automount of device(s) labeled GRMLCFG as requested." ; eend 0
+  ewarn "Skipping running automount of device(s) labeled $GRMLCFG as requested." ; eend 0
 else
   if [ -z "$INSTALLED" ] ; then
     if checkbootparam 'myconfig' ; then
 else
   if [ -z "$INSTALLED" ] ; then
     if checkbootparam 'myconfig' ; then
@@ -1801,7 +1804,7 @@ else
         eerror "Error: No device for bootoption myconfig provided." ; eend 1
       fi # [ -z "$DCSDEVICE" ]
     elif checkvalue $CONFIG_MYCONFIG; then # checkbootparam myconfig
         eerror "Error: No device for bootoption myconfig provided." ; eend 1
       fi # [ -z "$DCSDEVICE" ]
     elif checkvalue $CONFIG_MYCONFIG; then # checkbootparam myconfig
-      einfo "Searching for device(s) labeled with GRMLCFG. (Disable this via boot option: noautoconfig)" ; eend 0
+      einfo "Searching for device(s) labeled with $GRMLCFG. (Disable this via boot option: noautoconfig)" ; eend 0
       eindent
       # We do need the following fix so floppy disk is available to blkid in any case :-/
       if [ -r /dev/fd0 ] ; then
       eindent
       # We do need the following fix so floppy disk is available to blkid in any case :-/
       if [ -r /dev/fd0 ] ; then
@@ -1810,7 +1813,7 @@ else
            blkid /dev/fd0 >>$DEBUG 2>&1
         fi
       fi
            blkid /dev/fd0 >>$DEBUG 2>&1
         fi
       fi
-      DCSDEVICE=$(blkid -t LABEL=GRMLCFG | head -1 | awk -F: '{print $1}')
+      DCSDEVICE=$(blkid -t LABEL=$GRMLCFG | head -1 | awk -F: '{print $1}')
       if [ -n "$DCSDEVICE" ]; then
         DCSMP="/mnt/grmlcfg"
       fi
       if [ -n "$DCSDEVICE" ]; then
         DCSMP="/mnt/grmlcfg"
       fi
index 9c7e8fe..3b48cc4 100644 (file)
@@ -13,7 +13,9 @@ The DCS directory defaults to the root directory of the GRML live image. If a
 file system labeled GRMLCFG is found, the DCS directory is the root directory of
 that file system. Alternatively, the myconfig boot parameter can be used to
 directly specify a device which is then taken as DCS directory
 file system labeled GRMLCFG is found, the DCS directory is the root directory of
 that file system. Alternatively, the myconfig boot parameter can be used to
 directly specify a device which is then taken as DCS directory
-(myconfig=/dev/sda1, for example).
+(myconfig=/dev/sda1, for example). If your device is labeled different to
+GRMLCFG the proper label can be set via the autoconfig boot parameter
+(autoconfig=SOMELABEL, for example).
 
 Without any additional boot parameters, the GCA at DCSDIR/config.tbz is
 automatically unpacked and DCSDIR/scrips/grml.sh is automatically executed on
 
 Without any additional boot parameters, the GCA at DCSDIR/config.tbz is
 automatically unpacked and DCSDIR/scrips/grml.sh is automatically executed on
@@ -34,6 +36,14 @@ myconfig::
   myconfig=/dev/sda1                        => read DCS from usb-device
   myconfig=/dev/fd0                         => read DCS from floppy-disk
 
   myconfig=/dev/sda1                        => read DCS from usb-device
   myconfig=/dev/fd0                         => read DCS from floppy-disk
 
+autoconfig::
+
+   This parameter specifies the label used to determine the DCS device.
+   If undefined the label GRMLCFG is used to find the DCS device.
+
+  autoconfig=SOMELABEL      => search for device labeled SOMELABEL to use as
+                               DCS device.
+
 home::
 
     This parameter is for setting a specific partition as home directory.  Usage
 home::
 
     This parameter is for setting a specific partition as home directory.  Usage
diff --git a/tests/test_grmlcfg.sh b/tests/test_grmlcfg.sh
new file mode 100755 (executable)
index 0000000..308593f
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/zsh
+
+EXPECTED_LABEL=''
+TMPNAME=$(mktemp)
+
+export_var() {
+       echo $1=$(eval echo $"$1") >> $TMPNAME
+}
+
+blkid() {
+       echo > "$TMPNAME"
+       while [ -n "$1" ] ; do
+         case "$1" in
+               LABEL*)
+               assertEquals "unexpected label value"  "${EXPECTED_LABEL:-GRMLCFG}" "${1/LABEL=/}" >&2
+               export_var __shunit_testSuccess
+               export_var __shunit_assertsFailed
+               export_var __shunit_assertsTotal
+         esac
+         shift
+       done
+}
+
+test_grmlcfg() {
+       CONFIG_MYCONFIG='yes'
+       INSTALLED=""
+
+       EXPECTED_LABEL=''
+       CMDLINE=""
+       config_finddcsdir >/dev/null
+       . "$TMPNAME"
+
+       EXPECTED_LABEL='test1'
+       CMDLINE="autoconfig=$EXPECTED_LABEL"
+       config_finddcsdir >/dev/null
+       . "$TMPNAME"
+}
+
+
+tearDown() {
+       rm "$TMPNAME"
+}
+
+. ./common_tests $0