Hotplug can bring up/down interfaces now

Bryan Kadzban bryan at kadzban.is-a-geek.net
Mon Jul 5 14:33:47 PDT 2004


Nathan Coulson wrote:
> Yknow, it'll be neat if we had something like this...
> 
> Bringing up ETH0: [protocol 1, protocol 2, e.t.c]          [ OK/FAIL ]
> failed to bring up [protocol 4, protocol 5]
> 
> Zack has been doing some simular things in other scripts, if you want
> a reference.

I didn't take a look at Zack's implementation, but here's a stab at that
anyway (apply this instead of the previous patch, not on top of it).

Since the actual diff doesn't (IMO) make it obvious what I did, let me
explain it a bit.  The service files (in $network_devices/services/)
don't print the "bringing up interface $1" messages anymore, that's been
moved to the ifup/down scripts since they can call multiple service
scripts.  Those messages should be (IMO) per interface, not per service.

The service scripts indicate success or failure of doing whatever it is
that they do by their exit status.  (In the static service script, this
is the exit status of ifconfig (or ip, in an iproute2 scenario), which
is saved until the end in $retval -- other service scripts may not have
to do this, depending on what checks they do.)

The ifup/down scripts keep track of which services didn't have scripts
in the $unknown variable.  They keep track of which services succeeded
and which ones failed in $success and $failed.  These are basically just
space separated lists, though with a bit more work they could be comma
separated easily enough (they are not used to iterate or anything, they
are only ever echo'ed).

As the ifup/down scripts iterate through services, they add the service
name to the appropriate variable depending on what happened.

At the end, they print a FAILED status if either:

(1) Any service didn't have a script, or
(2) All scripts exited with a failure status.

If all scripts exist and at least one of them succeeds, then they print
an OK status (plus appropriate messages if any failed).

As many services as possible get started (even if some are unknown).
The ones that don't get started for whatever reason do get shown, so the
user can investigate.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: multiple-services-2.patch
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-dev/attachments/20040705/4089d3c5/attachment.ksh>


More information about the lfs-dev mailing list