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

Re: RFC: new network config (was: Re: network configuration)

In article <cistron.19990205190507.E12960@taz.net.au>,
Craig Sanders  <cas@taz.net.au> wrote:
>e.g. a config file like this:
>    #IP:domain:username:CGI?:Analog?
>    x.x.x.x:www.foo.bar:foobar:Y:Y

Config files with fixed fields are evil. Really evil.

Please pick another format:

interface {
	dev = eth0
	secondary = yes/no
	ip = foo
	netmask = bar
	route = baz


interface.eth0.ip =
interface.eth0.mask =

etc. The last on is more easy to script;


INT="`sed -n -e 's/^interface\.\([a-z0-9\-]\+\)\..*$/\1/p' < $CONF | sort -u`"
echo $INT
for i in $INT
        ip=`sed -n -e "s/^interface.$i.ip.*=\(.*\)\$/\1/p" < $CONF`
        mask=`sed -n -e "s/^interface.$i.mask.*=\(.*\)\$/\1/p" < $CONF`
        echo "interface $i, ip $ip, mask $mask"

But this is SLOW. It'd be better to do it in perl. Or awk, maybe.

Indifference will certainly be the downfall of mankind, but who cares?

Reply to: