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
}
or
interface.eth0.ip = 192.168.1.1
interface.eth0.mask = 255.255.255.0
etc. The last on is more easy to script;
CONF=/etc/ip.conf
INT="`sed -n -e 's/^interface\.\([a-z0-9\-]\+\)\..*$/\1/p' < $CONF | sort -u`"
echo $INT
for i in $INT
do
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"
done
But this is SLOW. It'd be better to do it in perl. Or awk, maybe.
Mike.
--
Indifference will certainly be the downfall of mankind, but who cares?
Reply to: