Subject: Re: misc/1919: merging functionality of netstart, etc, into rc
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: None <Chris_G_Demetriou@NIAGARA.NECTAR.CS.CMU.EDU>
List: netbsd-bugs
Date: 01/10/1996 02:35:41
> On Wed, 10 Jan 1996 12:38:39 +1100 
>  Luke Mewburn <lukem@supp.cpr.itg.telecom.com.au> wrote:
> 
>  > 	After the changes, the following files are superfluous and can
>  > 	be removed from the src tree and /etc:
>  > 		ifaliases
>  > 		myname
>  > 		mygate
>  > 		defaultdomain
>  > 		hostname.*
>  > 		netstart
> 
> The problem with this approach is that it makes it more difficult for 
> install scripts to work configuration magic.  Note how the sparc and 
> hp300 install scripts have an easy time configuring network interfaces, 
> hostname, etc. by simply creating the appropriate files, rather than 
> having to go through a complex editing process on a file which won't 
> contain any special keywords like __REPLACE_ME, or whatever.

If /etc/rc.conf is 'done right', install scripts should be able to go
through it without 'complex editing.'

consider two things:
	(1) an "/etc/rc.conf" file, which contains certain variables,
		etc.
	(2) an "/etc/format.rc.conf" file, which spits out a
	    properly-formed /etc/rc.conf to stdout.  (OK, the name
	    suck.  8-)

with something like that, to change a configuration variable (in sh)
you'd do:

. /etc/rc.conf
CONFIG_VARIABLE=foobar

mv /etc/rc.conf /etc/rc.conf.bak
. /etc/format.rc.conf > /etc/rc.conf

'format.rc.conf' would do the right magic to spit out the right format
file, and could be arbitrarily complex, e.g. looking something like:

# foo comment should go here

version='$NetBSD$'

cat <<- __EOF__
# DO NOT GENERATE THIS FILE BY HAND; IT IS AUTOMATICALLY GENERATED
# WITH ... VERSION $version

# The 'HOSTNAME' variable sets foo...
HOSTNAME="$HOSTNAME"

# The 'DOMAINNAME' variable sets bar ...
DOMAINNAME="$DOMAINNAME"

# The 'NETIFS' variable lists baz ...
NETIFS="$NETIFS"

__EOF__

for netif in $NETIFS; do
	echo "# Network interface configuration for $netif"
	echo -n "NETIF_${netif}_FAMILY="
	eval echo \\\"\$NETIF_${netif}_FAMILY\\\"
	echo "# etc."
	echo ""
done

# etc.


You could probably even skimp a bit on some of the quites, if you
wanted.  8-)


This gets you:
	(1) single configuration file (which, for all of the standard
	    networking stuff would seem to be a good idea),
	(2) easy automatic configuration, and
	(3) easy manual configuration (you actually _can_ edit the
	    file, and no harm will come of it, other than that
	    comments added by hand will be removed by the format
	    script).

it arguably breaks down in the face of packages, because the 'format'
script needs to know what variables are valid, etc., so that it can
spit them out.

I don't think that's a problem, though, because:
	(1) third-party packages are a pain in the butt right now,
	    anyway, and to my mind fixing them means moving to
	    an init.d scheme, and
	(2) if you do go to an init.d scheme, using seperate
	    config files for each package (or at least for each
	    vendor) makes quite a bit of sense, so there's no big
	    problem...


chris