Add support for overriding values via autoconfig.local
authorUlrich Dangel <mru@grml.org>
Sat, 12 Sep 2009 12:05:36 +0000 (14:05 +0200)
committerUlrich Dangel <mru@grml.org>
Sat, 12 Sep 2009 21:57:08 +0000 (23:57 +0200)
Adjusted sbin/grml-autoconfig to write changes to this new file
Updated documentation

autoconfig
autoconfig.local [new file with mode: 0644]
debian/rules
doc/grml-autoconfig.8.txt
sbin/grml-autoconfig

index 10ea222..2cfb247 100644 (file)
@@ -1,11 +1,17 @@
 # Filename:      /etc/grml/autoconfig
 # Filename:      /etc/grml/autoconfig
-# Purpose:       configuration for grml-autoconfig
+# Purpose:       global configuration for grml-autoconfig
 # 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.
 ################################################################################
 
 ################################################################################
 # 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.
 ################################################################################
 
 ################################################################################
+# Notice: Please do not edit this file! Use grml-autoconfig or
+# /etc/grml/autoconfig.local instead!
+################################################################################
+
+
+################################################################################
 # Notice: you can configure grml-autoconfig via adjusting the following values.
 # Set them to 'yes' to activate them and to 'no' to deactivate them.
 # But please notice that some options might require an additional bootparam
 # Notice: you can configure grml-autoconfig via adjusting the following values.
 # Set them to 'yes' to activate them and to 'no' to deactivate them.
 # But please notice that some options might require an additional bootparam
@@ -117,4 +123,12 @@ CONFIG_VMWARE='yes'           # vmware specific stuff (use xorg.conf.vmware)
 CONFIG_WELCOME='yes'          # play welcome sound (audio)
 CONFIG_WONDERSHAPER='yes'     # start wondershaper with options provided via bootparam
 CONFIG_XSTARTUP='yes'         # start X window system via grml-x [only in live-mode]
 CONFIG_WELCOME='yes'          # play welcome sound (audio)
 CONFIG_WONDERSHAPER='yes'     # start wondershaper with options provided via bootparam
 CONFIG_XSTARTUP='yes'         # start X window system via grml-x [only in live-mode]
+
+
+# config for local configuration file
+
+CONFIG_AUTOCONFIG_LOCAL='/etc/grml/autoconfig.local'
+
+[ -e ${CONFIG_AUTOCONFIG_LOCAL} ] && . ${CONFIG_AUTOCONFIG_LOCAL}
+
 ## END OF FILE #################################################################
 ## END OF FILE #################################################################
diff --git a/autoconfig.local b/autoconfig.local
new file mode 100644 (file)
index 0000000..11ffbba
--- /dev/null
@@ -0,0 +1,6 @@
+# Filename:      /etc/grml/autoconfig.local
+# Purpose:       local configuration for grml-autoconfig
+# 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.
+################################################################################
index 1cb8462..834d890 100755 (executable)
@@ -35,6 +35,7 @@ install: build
        # Add here commands to install the package into debian/grml-autoconfig.
        install -m 755 grml-autoconfig      debian/grml-autoconfig/etc/init.d/grml-autoconfig
        install -m 644 autoconfig           debian/grml-autoconfig/etc/grml/autoconfig
        # Add here commands to install the package into debian/grml-autoconfig.
        install -m 755 grml-autoconfig      debian/grml-autoconfig/etc/init.d/grml-autoconfig
        install -m 644 autoconfig           debian/grml-autoconfig/etc/grml/autoconfig
+       install -m 644 autoconfig.local     debian/grml-autoconfig/etc/grml/autoconfig.local
        install -m 755 autoconfig.functions debian/grml-autoconfig/etc/grml/autoconfig.functions
        install -m 644 language-functions   debian/grml-autoconfig/etc/grml/language-functions
        install -m 755 sbin/grml-autoconfig debian/grml-autoconfig/usr/sbin/grml-autoconfig
        install -m 755 autoconfig.functions debian/grml-autoconfig/etc/grml/autoconfig.functions
        install -m 644 language-functions   debian/grml-autoconfig/etc/grml/language-functions
        install -m 755 sbin/grml-autoconfig debian/grml-autoconfig/usr/sbin/grml-autoconfig
index ef53e16..9a582a6 100644 (file)
@@ -61,10 +61,15 @@ Dialog interface to the configuration file /etc/grml/autoconfig.
 
   */etc/grml/autoconfig*::
 
 
   */etc/grml/autoconfig*::
 
-Configuration file for grml-autoconfig framework. You can either edit this
-configuration file manually of use the dialog interface
+Default configuration file for grml-autoconfig framework.  You can override
+settings via /etc/grml/autoconfig.local or use the dialog interface
 /usr/sbin/grml-autoconfig.
 
 /usr/sbin/grml-autoconfig.
 
+  */etc/grml/autoconfig.local*::
+User specific configuration file for grml-autoconfig. You can edit it directly
+or use the dialog interface /usr/sbin/grml-autoconfig.
+
+
   */etc/grml/autoconfig.functions*::
 
 Main functions of the grml-autoconfig. You do not need to configure or execute
   */etc/grml/autoconfig.functions*::
 
 Main functions of the grml-autoconfig. You do not need to configure or execute
index 0abc8f8..9806ac3 100755 (executable)
@@ -18,15 +18,19 @@ TMPFILE="$(mktemp)"
 AUTOCONFIG=/etc/grml/autoconfig
 [ -r $AUTOCONFIG ] || exit 1
 
 AUTOCONFIG=/etc/grml/autoconfig
 [ -r $AUTOCONFIG ] || exit 1
 
+. $AUTOCONFIG
+
 # helper functions
 activate_value()
 {
 # helper functions
 activate_value()
 {
-  sed -i "s/$1.*/$1'yes'/" $AUTOCONFIG
+  check_entry $1
+  sed -i "s/$1.*/$1'yes'/" ${CONFIG_AUTOCONFIG_LOCAL}
 }
 
 deactivate_value()
 {
 }
 
 deactivate_value()
 {
-  sed -i "s/$1.*/$1'no'/" $AUTOCONFIG
+  check_entry $1
+  sed -i "s/$1.*/$1'no'/" ${CONFIG_AUTOCONFIG_LOCAL}
 }
 
 check_setting()
 }
 
 check_setting()
@@ -34,17 +38,28 @@ check_setting()
   grep -q $* $TMPFILE && return 0 || return 1
 }
 
   grep -q $* $TMPFILE && return 0 || return 1
 }
 
+check_entry()
+{
+  if ! grep -q ${1} ${CONFIG_AUTOCONFIG_LOCAL} 2>/dev/null ; then
+    grep $1 ${AUTOCONFIG} >> ${CONFIG_AUTOCONFIG_LOCAL}
+  fi
+}
+
+is_set()
+{
+    [ $1 = 'yes' ] && return 0 || return 1
+}
 check_current_state()
 {
 check_current_state()
 {
-  grep -q '^CONFIG_DHCP=.*yes'     $AUTOCONFIG && DHCPSTATUS=ON     || DHCPSTATUS=OFF
+  is_set $CONFIG_DHCP       && DHCPSTATUS=ON     || DHCPSTATUS=OFF
   if [ "$(grep '^auto' /etc/network/interfaces | sed 's/ lo// ; s/auto// ; s/ //g')" != "" ] ; then
      DHCPSTATUS=OFF
   fi
   if [ "$(grep '^auto' /etc/network/interfaces | sed 's/ lo// ; s/auto// ; s/ //g')" != "" ] ; then
      DHCPSTATUS=OFF
   fi
-  grep -q '^CONFIG_FSTAB=.*yes'    $AUTOCONFIG && FSTABSTATUS=ON    || FSTABSTATUS=OFF
-  grep -q '^CONFIG_CPU=.*yes'      $AUTOCONFIG && CPUSTATUS=ON      || CPUSTATUS=OFF
-  grep -q '^CONFIG_ACPI_APM=.*yes' $AUTOCONFIG && ACPI_APMSTATUS=ON || ACPI_APMSTATUS=OFF
-  grep -q '^CONFIG_SYSLOG=.*yes'   $AUTOCONFIG && SYSLOGSTATUS=ON   || SYSLOGSTATUS=OFF
-  grep -q '^CONFIG_GPM=.*yes'      $AUTOCONFIG && GPMSTATUS=ON      || GPMSTATUS=OFF
+  is_set $CONFIG_FSTAB      && FSTABSTATUS=ON    || FSTABSTATUS=OFF
+  is_set $CONFIG_CPU        && CPUSTATUS=ON      || CPUSTATUS=OFF
+  is_set $CONFIG_ACPI_APM   && ACPI_APMSTATUS=ON || ACPI_APMSTATUS=OFF
+  is_set $CONFIG_SYSLOG     && SYSLOGSTATUS=ON   || SYSLOGSTATUS=OFF
+  is_set $CONFIG_GPM        && GPMSTATUS=ON      || GPMSTATUS=OFF
 }
 
 # main program
 }
 
 # main program
@@ -57,7 +72,7 @@ interface to activate or deactivate some features.
 If you do not know what to do at this stage just leave it untouched,
 the defaults are the recommended values.
 
 If you do not know what to do at this stage just leave it untouched,
 the defaults are the recommended values.
 
-All the configuration happens in the file /etc/grml/autoconfig - you can
+All the configuration happens in the file /etc/grml/autoconfig.local - you can
 edit it manually as well.
 " 0 0 0 \
 dhcp "check for network devices and run pump (get ip-address via DHCP)" $DHCPSTATUS \
 edit it manually as well.
 " 0 0 0 \
 dhcp "check for network devices and run pump (get ip-address via DHCP)" $DHCPSTATUS \