dj at linuxfromscratch.org
Mon Jul 18 22:29:06 PDT 2011
On 07/07/2011 02:53 PM, Bruce Dubbs wrote:
> The file I have in mind is /etc/sysconfig/network. I think we can use
> variables like
> Alternatively we could use something like:
If you really want to go to a single config file, why not take a peak at
how Ubuntu does their networking scripts then? I don't know how they
work internally, but parsing logic seems obvious enough on the surface.
The single config file, /etc/network/interfaces, is used there and looks
fairly nice and is certainly self explanatory:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
iface lo inet loopback
# The primary network interface
iface eth0 inet static
Seem easy enough to parse that...grep for "^auto" and pass field 2 to
ifup. Bryan's example works here too, just append the following to the file:
# Turn on Wake-On-LAN for eth0
iface eth0 ? WOL
The ifup script greps for all lines containing "^iface $1" (which also
has the type and service fields), record the line numbers found, get
type and service from those line numbers (f3 and f4 resp.), next line,
next line, next line until a ^#, empty line, or EOF is found. Pass the
following lines to the service script on a single line and let the
service script handle the arguments in a shifting while loop. Same
process for ifdown except to take the highest numbered line first. We
probably don't even need the type field.
Doesn't get to look any "nicer" than that for single config file and our
existing modular method for extending the available services can be
reused (although they'll require some modifications). We can even tear
down the interfaces properly based on a running cache constructed the
same way (as was suggested a few weeks ago in the LSB thread).
-- DJ Lucas
This message has been scanned for viruses and
dangerous content, and is believed to be clean.
More information about the lfs-dev