FS#17190 - [netcfg] 2.5rc1 auto wired ifplugd action script broken
Attached to Project:
Arch Linux
Opened by Michael Kreitzer (mrgrim) - Wednesday, 18 November 2009, 14:38 GMT
Last edited by Andrea Scarpino (BaSh) - Saturday, 22 January 2011, 10:00 GMT
Opened by Michael Kreitzer (mrgrim) - Wednesday, 18 November 2009, 14:38 GMT
Last edited by Andrea Scarpino (BaSh) - Saturday, 22 January 2011, 10:00 GMT
|
Details
Description:
There were many issues with the ifplugd netcfg.action script that needed to be addressed before auto-wired worked at all: First is this test on line 18: [[ $CONNECTION != @(ethernet|ethernet-iproute) ]] bash defaults to extglob disabled, and this construct is invalid without it. To corrected I added the following line before the case: shopt -s extglob Second, line 23: for profile in $(list profiles}; do I'm not sure how this happened. Looks like a pretty bad last minute fat finger w/o a test. Change to: for profile in $(list_profiles); do Third, line 26: [[ $CONNECTION != "(ethernet|ethernet-iproute)" ]] && continue This will never match. I'm certain a construct using @(..) identical to the one in the first loop was intended: [[ $CONNECTION != @(ethernet|ethernet-iproute) ]] && continue Fourth, the parenthesis around the two for loops cause bash to execute the loop body in a sub shell. This results in the exit commands exiting the sub shell and not the script proper. Ultimately this ends up in all profiles for an interface being attempted twice as both loops will complete (exit can be considered to act like a continue when the loop body is surrounded by parenthesis). This also causes the "exit 1" at the end of the script to always be reached causing ifplugd to think the action script always fails. I'm attaching the full script after my modifications which works for me. Thanks, Michael |
This task depends upon
Closed by Andrea Scarpino (BaSh)
Saturday, 22 January 2011, 10:00 GMT
Reason for closing: Fixed
Additional comments about closing: http://projects.archlinux.org/netcfg.git /commit/?id=0fc35b1462b3257653ebca6d2df6 5a6062a2194a
Saturday, 22 January 2011, 10:00 GMT
Reason for closing: Fixed
Additional comments about closing: http://projects.archlinux.org/netcfg.git /commit/?id=0fc35b1462b3257653ebca6d2df6 5a6062a2194a
The problem still exists in the git version of netcfg.action file:
http://projects.archlinux.org/netcfg.git/tree/ifplugd/netcfg.action
Simple patch:
17c17
< for profile in $(list_profiles); do
---
> for profile in $(list_profiles); do (
26,27c26,27
< done
< for profile in "${static_profiles[@]}"; do
---
> ) done
> for profile in "${static_profiles[@]}"; do (
30c30
< done
---
> ) done
for profile in $(list_profiles); do (
load_profile "$profile"
[[ "$INTERFACE" != "$1" ]] && continue
[[ "$CONNECTION" != @(ethernet|ethernet-iproute) ]] && continue
if [[ "$IP" == "dhcp" ]]; then
netcfg "$profile" && exit 1
else
static_profiles+=("$profile")
fi
) || exit 0; done
the declare static_profiles is not working.
I don't understand the whole magic, but static_profiles is not reaching the second for loop.
It's empty, probably because the subshell exits and removes static_profile.
I agree that NETWORKS=() in rc.conf perhaps would not be currently the best place for selecting the net-auto-wired profile. In fact I tested such scenario by modifying the scripts, but the profile became loaded two times during boot: one from /etc/rc.d/net-profiles and a second from /etc/rc.d/net-auto-wired (ifplugd), this last one ending with an error in syslog because it was already loaded. A better solution it could have been a new AUTO_NETWORKS=() setting in rc.conf to select the auto _profile_, and using them to infere the interface(s) either wired or wireless (instead of the current WIRED_INTERFACE and WIRELESS_INTERFACE settings). But this would need a lot of changes, and would break the current way of doing the things.
In my case I finally have improved the Profjim solution to "flag" a particular profile as the "default" for auto start. If the profile makes true the AUTO_WIRED variable, such profile will be selected (even if there are dhcp ones). Thus the precedence is: AUTO_WIRED flagged profile -> any dhcp profile -> any static profile. If there are several AUTO_WIRED profiles for that network interface, the action script ends with error. Here I attach my netcfg.action customization, in case it helps.