X-Git-Url: http://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=sbin%2Fgrml-autoconfig;h=e2147a79ef384f41f7092e4a08936e504c3b3a18;hp=0abc8f89203bafe3cda465ba63090f63cb934e73;hb=3cb99a2f480e6012c09528a49514fafed3073d7d;hpb=724713da63a47e2dd8aa7e7a180ae9d2d891b672 diff --git a/sbin/grml-autoconfig b/sbin/grml-autoconfig index 0abc8f8..e2147a7 100755 --- a/sbin/grml-autoconfig +++ b/sbin/grml-autoconfig @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Filename: grml-autoconfig # Purpose: configuration interface for grml-autoconfig # Authors: grml-team (grml.org), (c) Michael Prokop @@ -6,7 +6,7 @@ # License: This file is licensed under the GPL v2. ################################################################################ -if [ "$UID" != 0 ]; then +if [ $(id -u) != 0 ] ; then echo "Error: please run this script with uid 0 (root)." ; exit 1 fi @@ -18,15 +18,19 @@ TMPFILE="$(mktemp)" AUTOCONFIG=/etc/grml/autoconfig [ -r $AUTOCONFIG ] || exit 1 +. $AUTOCONFIG + # 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() { - sed -i "s/$1.*/$1'no'/" $AUTOCONFIG + check_entry $1 + sed -i "s/$1.*/$1'no'/" ${CONFIG_AUTOCONFIG_LOCAL} } check_setting() @@ -34,36 +38,46 @@ check_setting() grep -q $* $TMPFILE && return 0 || return 1 } -check_current_state() +check_entry() { - grep -q '^CONFIG_DHCP=.*yes' $AUTOCONFIG && DHCPSTATUS=ON || DHCPSTATUS=OFF - if [ "$(grep '^auto' /etc/network/interfaces | sed 's/ lo// ; s/auto// ; s/ //g')" != "" ] ; then - DHCPSTATUS=OFF + if ! grep -q ${1} ${CONFIG_AUTOCONFIG_LOCAL} 2>/dev/null ; then + grep $1 ${AUTOCONFIG} >> ${CONFIG_AUTOCONFIG_LOCAL} 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() +{ + [ $1 = 'yes' ] && return 0 || return 1 +} +check_current_state() +{ + is_set $CONFIG_FSTAB && FSTABSTATUS=ON || FSTABSTATUS=OFF + is_set $CONFIG_CPU && CPUSTATUS=ON || CPUSTATUS=OFF + is_set $CONFIG_ACPI && ACPISTATUS=ON || ACPISTATUS=OFF + is_set $CONFIG_SYSLOG && SYSLOGSTATUS=ON || SYSLOGSTATUS=OFF + is_set $CONFIG_GPM && GPMSTATUS=ON || GPMSTATUS=OFF } # main program interface() { - dialog --cr-wrap --clear --cancel-label "Exit" --title "$PN" --checklist "grml-autoconfig is the framework which includes hardware -detection, activation of system services and this is the + dialog --cr-wrap --clear --cancel-label "Exit" --title "$PN" --checklist \ +"grml-autoconfig is the framework which includes hardware +detection, activation of system services. 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, -the defaults are the recommended values. +If you do not know what to do at this stage just leave it untouched. + +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 " 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 \ -cpufreq "activate cpydyn/powernowd for frequency-scalable CPUs" $CPUSTATUS \ -acpi_apm "load ACPI/APM modules" $ACPI_APMSTATUS \ +cpufreq "activate cpu frequency scaling" $CPUSTATUS \ +acpi "load ACPI modules" $ACPISTATUS \ syslog "start syslog-ng" $SYSLOGSTATUS \ gpm "start GPM (mouse on console)" $GPMSTATUS \ 2>$TMPFILE @@ -71,10 +85,9 @@ gpm "start GPM (mouse on console)" $GPMSTATUS \ set_values() { - check_setting dhcp && activate_value CONFIG_DHCP= || deactivate_value CONFIG_DHCP= check_setting fstab && activate_value CONFIG_FSTAB= || deactivate_value CONFIG_FSTAB= check_setting cpufreq && activate_value CONFIG_CPU= || deactivate_value CONFIG_CPU= - check_setting acpi_apm && activate_value CONFIG_ACPI_APM= || deactivate_value CONFIG_ACPI_APM= + check_setting acpi && activate_value CONFIG_ACPI= || deactivate_value CONFIG_ACPI= check_setting syslog && activate_value CONFIG_SYSLOG= || deactivate_value CONFIG_SYSLOG= check_setting gpm && activate_value CONFIG_GPM= || deactivate_value CONFIG_GPM= }