Skip to content

Commit

Permalink
Add support for overriding values via autoconfig.local
Browse files Browse the repository at this point in the history
Adjusted sbin/grml-autoconfig to write changes to this new file
Updated documentation
  • Loading branch information
mrud committed Sep 12, 2009
1 parent 1e3aa3c commit 994a5c3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 12 deletions.
16 changes: 15 additions & 1 deletion autoconfig
@@ -1,10 +1,16 @@
# 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> # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/ # Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2. # 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. # Notice: you can configure grml-autoconfig via adjusting the following values.
# Set them to 'yes' to activate them and to 'no' to deactivate them. # Set them to 'yes' to activate them and to 'no' to deactivate them.
Expand Down Expand Up @@ -117,4 +123,12 @@ CONFIG_VMWARE='yes' # vmware specific stuff (use xorg.conf.vmware)
CONFIG_WELCOME='yes' # play welcome sound (audio) CONFIG_WELCOME='yes' # play welcome sound (audio)
CONFIG_WONDERSHAPER='yes' # start wondershaper with options provided via bootparam 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_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 #################################################################
6 changes: 6 additions & 0 deletions autoconfig.local
@@ -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.
################################################################################
1 change: 1 addition & 0 deletions debian/rules
Expand Up @@ -35,6 +35,7 @@ install: build
# Add here commands to install the package into debian/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 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 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 755 autoconfig.functions debian/grml-autoconfig/etc/grml/autoconfig.functions
install -m 644 language-functions debian/grml-autoconfig/etc/grml/language-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 sbin/grml-autoconfig debian/grml-autoconfig/usr/sbin/grml-autoconfig
Expand Down
9 changes: 7 additions & 2 deletions doc/grml-autoconfig.8.txt
Expand Up @@ -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 Default configuration file for grml-autoconfig framework. You can override
configuration file manually of use the dialog interface 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*:: */etc/grml/autoconfig.functions*::


Main functions of the grml-autoconfig. You do not need to configure or execute Main functions of the grml-autoconfig. You do not need to configure or execute
Expand Down
33 changes: 24 additions & 9 deletions sbin/grml-autoconfig
Expand Up @@ -18,33 +18,48 @@ TMPFILE="$(mktemp)"
AUTOCONFIG=/etc/grml/autoconfig AUTOCONFIG=/etc/grml/autoconfig
[ -r $AUTOCONFIG ] || exit 1 [ -r $AUTOCONFIG ] || exit 1


. $AUTOCONFIG

# helper functions # helper functions
activate_value() 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()
{ {
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 if [ "$(grep '^auto' /etc/network/interfaces | sed 's/ lo// ; s/auto// ; s/ //g')" != "" ] ; then
DHCPSTATUS=OFF DHCPSTATUS=OFF
fi fi
grep -q '^CONFIG_FSTAB=.*yes' $AUTOCONFIG && FSTABSTATUS=ON || FSTABSTATUS=OFF is_set $CONFIG_FSTAB && FSTABSTATUS=ON || FSTABSTATUS=OFF
grep -q '^CONFIG_CPU=.*yes' $AUTOCONFIG && CPUSTATUS=ON || CPUSTATUS=OFF is_set $CONFIG_CPU && CPUSTATUS=ON || CPUSTATUS=OFF
grep -q '^CONFIG_ACPI_APM=.*yes' $AUTOCONFIG && ACPI_APMSTATUS=ON || ACPI_APMSTATUS=OFF is_set $CONFIG_ACPI_APM && ACPI_APMSTATUS=ON || ACPI_APMSTATUS=OFF
grep -q '^CONFIG_SYSLOG=.*yes' $AUTOCONFIG && SYSLOGSTATUS=ON || SYSLOGSTATUS=OFF is_set $CONFIG_SYSLOG && SYSLOGSTATUS=ON || SYSLOGSTATUS=OFF
grep -q '^CONFIG_GPM=.*yes' $AUTOCONFIG && GPMSTATUS=ON || GPMSTATUS=OFF is_set $CONFIG_GPM && GPMSTATUS=ON || GPMSTATUS=OFF
} }


# main program # main program
Expand All @@ -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, If you do not know what to do at this stage just leave it untouched,
the defaults are the recommended values. 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. edit it manually as well.
" 0 0 0 \ " 0 0 0 \
dhcp "check for network devices and run pump (get ip-address via DHCP)" $DHCPSTATUS \ dhcp "check for network devices and run pump (get ip-address via DHCP)" $DHCPSTATUS \
Expand Down

0 comments on commit 994a5c3

Please sign in to comment.