Documented debnet parameter
[grml-autoconfig.git] / sbin / grml-autoconfig
index 1bf1dae..dcb679a 100755 (executable)
@@ -1,34 +1,36 @@
-#!/bin/sh
+#!/bin/bash
 # Filename:      grml-autoconfig
 # Purpose:       configuration interface for grml-autoconfig
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika(at)grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
 # Filename:      grml-autoconfig
 # Purpose:       configuration interface for grml-autoconfig
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika(at)grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Don Mär 29 11:30:33 CEST 2007 [mika]
 ################################################################################
 
 ################################################################################
 
-if [ "$UID" != 0 ];  then
+if [ $(id -u) != 0 ] ; then
   echo "Error: please run this script with uid 0 (root)." ; exit 1
 fi
 
 LANG=C
 LC_ALL=C
   echo "Error: please run this script with uid 0 (root)." ; exit 1
 fi
 
 LANG=C
 LC_ALL=C
-PN=`basename "$0"`
-TMPFILE=`mktemp`
-
-grep -q small /etc/grml_version 2>/dev/null && AUTOCONFIG=/etc/grml/autoconfig.small || AUTOCONFIG=/etc/grml/autoconfig
+PN="$(basename $0)"
+TMPFILE="$(mktemp)"
 
 
+AUTOCONFIG=/etc/grml/autoconfig
 [ -r $AUTOCONFIG ] || exit 1
 
 [ -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()
@@ -36,14 +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
-  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_DHCP       && DHCPSTATUS=ON     || DHCPSTATUS=OFF
+  if [ "$(grep '^auto' /etc/network/interfaces | sed 's/ lo// ; s/auto// ; s/ //g')" != "" ] ; then
+     DHCPSTATUS=OFF
+  fi
+  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
@@ -54,10 +70,15 @@ detection, activation of system services and this is the
 interface to activate or deactivate some features.
 
 If you do not know what to do at this stage just leave it untouched,
 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.
+the defaults represent the recommended values.
+
+All the configuration happens in the file /etc/grml/autoconfig.local -
+you can edit the file manually as well.
 
 
-All the configuration happens in the file /etc/grml/autoconfig - you can
-edit it manually as well.
+Please do not confuse these settings with plain Debian configuration.
+For example disabling dhcp here will NOT deactivate any configured network
+settings in /etc/network/interfaces, it just configures grml-autoconfig
+related settings instead.
 " 0 0 0 \
 dhcp "check for network devices and run pump (get ip-address via DHCP)" $DHCPSTATUS \
 fstab "update /etc/fstab entries (check for devices)" $FSTABSTATUS \
 " 0 0 0 \
 dhcp "check for network devices and run pump (get ip-address via DHCP)" $DHCPSTATUS \
 fstab "update /etc/fstab entries (check for devices)" $FSTABSTATUS \