[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

/etc/sysconfig or /etc/hostconfig (was Re: /etc/default)



it seems to me that there are two types of "default" file being
discussed here.

The first is default options for executables - i.e. /etc/default. Most
discussion so far has concentrated on this. This will require massive
changes to the system so that binaries know how to use the default
information (e.g. tar has to be patched to use /etc/default/tar) unless
we have a way of converting these /etc/default/* files into the
relevant environment variables.


The second is boot time configuration information - information that
the system needs to boot up correctly...network address, what programs
to run, etc. This is probably a lot easier and simpler to implement as
we don't need to make any radical changes to the binaries to get the
benefits.

Some of the machines I use at work are FreeBSD, some are NextStep (my
personal workstation is Debian, of course...and is the most stable of
the lot. By example of my machine only i have convinced the boss that
debian linux is a damned good system :).

One thing I really like about BSD & NextStep is their /etc/sysconfig
(BSD) and /etc/hostconfig (NS) files.  (I know debian is sysV and not BSD
but a good idea is a good idea :) I tend to prefer the hostconfig file
because it's just a list of simple variables, each containing one value
only.


These contain simple directives like:

BSD: 

---cut here---extract of sample /etc/sysconfig---
hostname="host.domain.blah"
defaultdomainname=NO
tcp_extensions=YES
ipfirewall=YES
network_interfaces="ed0 lo0"
ifconfig_ed0="inet xxx.xxx.xxx.xxx netmask 255.255.255.0"
ifconfig_lo0="inet localhost"
route_loopback="${hostname} localhost"
defaultrouter=203.2.135.53
routedflags=NO
timedflags=NO
xntpdflags="NO"
tickadjflags="-Aq"
---cut here---sample /etc/sysconfig---

NextStep:

---cut here---sample /etc/hostconfig---
HOSTNAME=hostname
INETADDR=xxx.xxx.xxx.xxx
ROUTER=-ROUTED-
IPNETMASK=
IPBROADCAST=-AUTOMATIC-
NETMASTER=-YES-
YPDOMAIN=-NO-
TIME=-AUTOMATIC-
---cut here---sample /etc/hostconfig---


The nice thing about these types of files is that they're easily parsed in
sh.  In fact, they can even be sourced in an /etc/init.d/* script to provide
environment variables (although that might have undesirable side-effects).

If we use something like this, we would need:

    - an easy way for debian.{pre,post}{inst,rm} scripts to add, delete,
      and extract individual entries.  sed would do the trick for sh,
      and perl should have no problems at all with this format.

      When a usenet news related package is installed, it should
      examine this file to see if NEWS_SERVER is defined. If it is, it
      uses it. 

      If not, it should query the user and add a line like
      "NEWS_SERVER=hostname.domain". We should provide a standard
      script, which the postinst script calls to do this.


    - a defined standard for how /etc/init.d scripts should use this
      information.  e.g. source the file or:

              sed -n -e '/^NEWS_SERVER=/s/\([^=]*\)=\(.*\)/\2/p'


here's two simple examples of how this could be used:

---/etc/init.d/network---
#! /bin/sh

function extract_var() {
        sed -n -e "/^$1=/s/\([^=]*\)=\(.*\)/\2/p" /etc/hostconfig
}

IPADDR=`extract_var IPADDR`
NETMASK=`extract_var NETMASK`
NETWORK=`extract_var NETWORK`
BROADCAST=`extract_var BROADCAST`
GATEWAY=`extract_var GATEWAY`

/sbin/ifconfig eth0 ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST}

/sbin/route add -net ${NETWORK} eth0
/sbin/route add -net ${NETWORK} netmask ${NETMASK} >/dev/null 2>&1
/sbin/route add default gw ${GATEWAY} metric 1
---/etc/init.d/network---

or

---/etc/init.d/netstd_init---
#!/bin/sh
#
# Start networking daemons.

function extract_var() {
        sed -n -e "/^$1=/s/\([^=]*\)=\(.*\)/\2/p" /etc/hostconfig
}

NET="/usr/sbin"
ROUTER=`extract_var ROUTER`

case "$1" in
  start)
    if [ $ROUTER = ROUTED ] ; then
	   echo "Starting routed" ; start-stop-daemon --start --quiet --exec ${NET}/routed -- -q
	;;
    fi
    if [ $ROUTER = GATED ] ; then
	   echo "Starting gated" ; start-stop-daemon --start --quiet --exec ${NET}/gated 
	;;
    fi
  stop)
        start-stop-daemon --stop --quiet --oknodo --exec /usr/sbin/routed
        start-stop-daemon --stop --quiet --oknodo --exec /usr/sbin/gated
	;;
  *)
        echo "Usage: /etc/init.d/netstd_init {start|stop}"
        exit 1
esac

exit 0
---/etc/init.d/netstd_init---


food for thought, anyway...


Craig




Reply to: