it is always a bad idea to mix up different languages in one environment. Another point is, to bury awk in base-files. There is no reason for it, these are only quick hacks from the old days of whiterussian 8-).
i have also removed all the >/dev/null - statements, which are IMHO not neccesary anymore. there is also a check for an call without args. Signed-off-by: Bastian Bittorf <bittorf at bluebottle.com>
>From 43cd5dfefcf0527b295f445900b9d650f7dffc53 Mon Sep 17 00:00:00 2001 From: Bastian Bittorf <bitt...@bluebottle.com> Date: Sun, 16 Jan 2011 13:55:55 +0100 Subject: [PATCH] refactoring unbridge() without awk/grep --- package/base-files/files/lib/network/config.sh | 39 ++++++++++++++--------- 1 files changed, 24 insertions(+), 15 deletions(-) diff --git a/package/base-files/files/lib/network/config.sh b/package/base-files/files/lib/network/config.sh index 449d252..d166966 100755 --- a/package/base-files/files/lib/network/config.sh +++ b/package/base-files/files/lib/network/config.sh @@ -405,19 +405,28 @@ stop_interface_dhcp() { uci -P /var/state revert "network.$config" } -unbridge() { - local dev="$1" - local brdev - - [ -x /usr/sbin/brctl ] || return 0 - brctl show 2>/dev/null | grep "$dev" >/dev/null && { - # interface is still part of a bridge, correct that - - for brdev in $(brctl show | awk '$2 ~ /^[0-9].*\./ { print $1 }'); do - brctl delif "$brdev" "$dev" 2>/dev/null >/dev/null - do_sysctl net.ipv6.conf.$dev.disable_ipv6 0 - [ "${dev##wlan}" != "$dev" ] && \ - do_sysctl net.ipv6.conf.mon.$dev.disable_ipv6 0 - done - } +unbridge() +{ + local remove_dev="$1" + local brdev line + + [ ! -x /usr/sbin/brctl -o -z "$remove_dev" ] && return 0 + + brctl show | while read line; do { + case "$line" in + "bridge name"*) ;; # ignore headline + *) + set $line + brdev="$1" + + [ "$brdev" = "$remove_dev" ] && { + brctl delif "$brdev" "$remove_dev" + do_sysctl net.ipv6.conf.$remove_dev.disable_ipv6 0 + + [ "${remove_dev##wlan}" != "$remove_dev" ] && \ + do_sysctl net.ipv6.conf.mon.$remove_dev.disable_ipv6 0 + } + ;; + esac + } done } -- 1.6.3.3
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel