[RFC] Re: Multiple services per interface

Nathan Coulson conathan at conet.dyndns.org
Tue Jul 6 21:50:59 PDT 2004


> Bryan Kadzban wrote:
>
>> Wait, I can do it with another loop.  With SERVICE and IFS set up:
>>
>> for svc in $SERVICE
>> do
>>     # Add on to the beginning: reverse the string
>>     REVSVC="$svc,$REVSVC"
>> done
>>
>> # Remove the final pesky comma
>> REVSVC=${REVSVC%,}
>
> Yes, this is the proper method, although when you're building REVSVC you
> might as well use space delimiters; you won't need to trim the end, you
> won't have to have IFS set to anything special. It's not likely that
> someone would actually have a service name that contains a space :-)
>
> For that matter, I wouldn't be opposed to not using commas in the
> SERVICE variable either; I don't see a big difference between:
>
> SERVICE=static,ipx,pppoe
>
> and
>
> SERVICE="static ipx pppoe"
>
> except that the parsing logic is a bit simpler (no messing with IFS).
> --

jim (jg555?) on IRC gave me another idea, if people are willing to
consider it,  It is sortof like how grub, and lilo can handle multiple
partitions in a single configuration file.  (Brian, up to this?)

CONFIGUATION FILE:  [ifconfig.eth0]
ONBOOT=yes
SERVICE=static
IP=192.168.1.1
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
SERVICE=static
IP=192.168.1.2
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
SERVICE=ipx
#IPXDEV=eth0 Not needed, as in ifconfig.eth0
FRAME=802.2
END CONFIGURATION FILE

he gave me this line to play around with...  [Although it is structured
like Winkie's module loading script is]

for data in $DATA; do echo $data | { IFS='' read info1; echo "Info 1 =
$info1"; }; done


Anyway, a double subshell can handle it
(
  read until first SERVICE=, storing rest into environment
  (
    read until next SERVICE=, or EOF, storing rest into environment
    call /etc/sysconfig/network-devices/services/$SERVICE
  )
)

I like the way the information can be split apart better, instead of a
single SERVICE line.



More information about the lfs-dev mailing list