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

Re: dcfgtool and clones

On Sat, 31 May 1997, Richard G. Roberto wrote:

> Well, I promised myself I wasn't going to get involved in this kind of
> thing, but I'm about to get a private internet connection so I should
> be able to insulate my job from these discussions soon. I would like
> to make the following requests of those working on this project:
> Please do not create a proprietary configuration interface.

I couldn't agree more.

The config database should be regarded as a convenience for
{pre,post}{inst,rm} scripts and /etc/init.d/ boot time scripts only.

It should NOT attempt to be some universal replacement for
package-specific config files.

All that is needed is a set of "key=value" pairs in a plain text file.  Take
a look at FreeBSD's /etc/sysconfig or NextStep's /etc/hostconfig for an

This is not only simple to implement, but it is also simple to
parse...and it allows the sysadmin to change the setup with
vi/pico/ae/joe/emacs or whatever. Later, a GUI or web front end can be
layered ON TOP of this.

parsing the files in shell is simple:

    source /etc/sysconfig

parsing it in perl is almost as easy.  The following code fragment reads 
/etc/sysconfig into an associative array called $config.

    $sysconfig="/etc/sysconfig" ;
    open(SYSCONFIG,"$sysconfig") || die "can't open $sysconfig: $!\n" ;

    while (<SYSCONFIG>) {
            s/#.*$//;           # strip out comments
            next if /^$/ ;      # ignore blank lines
            ($variable, $value) = /^(.*)=(.*)/ ;
            $config{$variable} = $value ;
    } ;

    close(SYSCONFIG) ;

i'm not a great perl programmer, so the above can probably be improved.
i'm making myself NOT do everything in sh, and forcing myself to learn
how to do it in perl instead.

Here's some example usage of the array:

    print $config{hostname} ;
    print $config{ip_address} ;

    # print out the entire array:
    foreach $item (sort keys(%config)) {
        print $item, "=", $config{$item}, "\n" ;

This perl fragment is good enough for simple assignments like:


it's not yet smart enough to do:


but it wouldn't be hard to modify it to do so.

So, a decision needs to be made: whether to allow only simple
assignments or to also allow complicated assignments like 
"foo=`cat /etc/bar`". Parsing the former is easy in any scripting
language. Parsing the latter could get quite difficult in languages
other than sh.

at minimum, we need to support sh/bash/ksh/zsh, and perl. we should also
support csh and probably python.  The sh family are easy.  perl, csh,
python and others will require a "library" or set of standard code fragments
for parsing the /etc/sysconfig file.

we need code fragments in all of these languages to add, read, modify,
and delete (comment out) "name=value" pairs....and do it WITHOUT
disrupting any comments or the order of assignment statements in the

btw, i don't care what the file is called.  /etc/sysconfig is just an


craig sanders
networking consultant                  Available for casual or contract
temporary autonomous zone              system administration tasks.

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .

Reply to: