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

From: Craig Sanders <[email-masked]>
Date: Mon, 5 Aug 1996 10:28:35 +1000 (EST)

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

---

From: [email-masked] (Kai Henningsen)
Date: 08 Aug 1996 12:42:00 +0200

> changes to the system so that binaries know how to use the default

I'd really prefer if people don't put up straw men to attack a proposal.

Nowhere at all has the /etc/default proposal asked for massive changes to  
the system.

Nowhere at all has someone asked that tar be changed to support
/etc/default/tar.

This is just not true.

> environment variables (although that might have undesirable side-effects).

In fact, that is the *exact* syntax that /etc/default uses. Except that it  
doesn't throw unconnected stuff into the same file, which strikes me as a  
bad idea.

But then, that's very similar to the BSD style of rc scripts vs. the SysV  
style.

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

Why not simply source it?

Oh, I forgot - you lumped all of /etc/default together in one file.

Unnecessary complication. Besides, it makes for name clashes.

MfG Kai

---

From: Craig Sanders <[email-masked]>
Date: Sat, 24 Aug 1996 11:03:02 +1000 (EST)

sorry to take so long to reply to this...i've been too busy at work to
even check my mailing lists.

On 8 Aug 1996, Kai Henningsen wrote:

> > discussion so far has concentrated on this. This will require
> > massive changes to the system so that binaries know how to use the
> > default
>

1. i wasn't attacking ANY proposal.  I happen to think that /etc/default is
a great idea.

2. As mentioned in my message, i was concentrating on a side of the
issue which seemed to be being ignored: boot time configuration rather
than run-time defaults.

> Nowhere at all has the /etc/default proposal asked for massive changes
> to the system.
>

tar was just one example.

how is tar going to get its default options from /etc/default/tar if it
isn't hacked to read that file?

making changes to many programs to enable them to read /etc/default/*
files seems to me to qualify as 'massive changes to the system'.

> Why not simply source it?

sourcing it is good. however, people seem to be shifting towards using
perl rather than sh...sourcing a sh script in perl isn't going to be
terribly useful.

a file containing "token=value" lines, can be sourced by sh or the
values can be easily extracted in just about any language.

> Unnecessary complication. Besides, it makes for name clashes.

To tell the truth, it doesn't bother me too much whether there is one
file containing all configuration information or multiple files...if
debian ends up with multiple files in /etc/default, i'll just create a
Makefile & set of m4 rules to generate them all from a single file.

This will allow me to create my own config_info package which contains
the configuration defaults for all packages I'm interested in. Then,
when I build a new debian machine I can install my config_info package
just after installing base, but before installing the rest of the
system....

Craig

---

From: [email-masked] (Kai Henningsen)
Date: 27 Aug 1996 18:58:00 +0200

> even check my mailing lists.

Well, *I*'ve been on vacation. There's not much that I still want to  
comment on ...

> tar was just one example.

An example of how SysV uses this directory, yes.

> isn't hacked to read that file?

It isn't. *Nobody* said it had to.

> files seems to me to qualify as 'massive changes to the system'.

And this *was* *not* proposed.

Changing scripts to do this instead of using hardcoded values *was*  
proposed.

MfG Kai