Hi everybody,
I patched the /etc/rc.d/network script, to start network profiles in a
chain, and stop as soon as the first network successfully started.
Therefore I introduced a new modifier in /etc/rc.conf for the
NET_PROFILES line, the colon.
Little example:
/etc/rc.conf:
NET_PROFILES=(prof1 prof2 :prof3 prof4 :prof5)
prof1, prof2 and prof4 are started the "old" way.
prof3 and prof5 are stored in the chain and the script tries first to
start prof3, if it successes, prof5 is skipped.
Starting a profile can fail, if the cable is not plugged in (tested with
mii-tool), or there is no dhcp response (if dhcp is used).
Patch attached (cd /etc/rc.d/ ; patch < /path/to/network.patch)
what do you think?
keep kickin,
--peter
--- network_original 2007-03-24 23:28:39.000000000 +0100
+++ network 2007-03-24 23:07:26.000000000 +0100
@@ -164,6 +164,7 @@
exit
fi
+
# See if we're using network profiles
if [ "$NET" ]; then
# This env var is passed from the kernel boot line
@@ -176,11 +177,27 @@
if [ "$NET_PROFILES" = "menu" ]; then
/usr/bin/netcfg --menu --timeout 5
else
+ OR_NET_PROFILES=()
for prof in [EMAIL PROTECTED]; do
if [ "$prof" = "${prof#!}" ]; then
- /usr/bin/netcfg -c $prof
+ # If profile is not in or list start it
+ if [ "$prof" = "${prof#:}" ]; then
+ /usr/bin/netcfg -c $prof
+ else
+ OR_NET_PROFILES=([EMAIL PROTECTED] ${prof#:})
+ fi
fi
done
+ # tries to start one network profile after the other, and stopps
+ # trying at success
+ for prof in [EMAIL PROTECTED]; do
+ PROF_DEVICE=$(sed -n "s/^INTERFACE=\(.*\)/\1/p" /etc/network-profiles/$prof)
+ ifconfig $PROF_DEVICE up
+ if [ ! "$(mii-tool $PROF_DEVICE 2>/dev/null|grep "no link")" ]; then
+ /usr/bin/netcfg -c $prof && break
+ fi
+ ifconfig $PROF_DEVICE down
+ done
fi
fi
_______________________________________________
arch mailing list
[email protected]
http://www.archlinux.org/mailman/listinfo/arch