summaryrefslogtreecommitdiff
path: root/package/base-files-network/files
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-04-30 18:23:56 +0000
committerFelix Fietkau <nbd@openwrt.org>2012-04-30 18:23:56 +0000
commit4ea86b956c3ba4ed4ae7c20ea1849bfb7004f97a (patch)
tree5caec098b96f18ad5ff2ad7058ae0f98a6127577 /package/base-files-network/files
parent8a790d97308153c345abfd27e5693b688fc3ba89 (diff)
downloadmtk-20170518-4ea86b956c3ba4ed4ae7c20ea1849bfb7004f97a.zip
mtk-20170518-4ea86b956c3ba4ed4ae7c20ea1849bfb7004f97a.tar.gz
mtk-20170518-4ea86b956c3ba4ed4ae7c20ea1849bfb7004f97a.tar.bz2
base-files-network: add a fixup_interface function like with the netifd compatibility scripts - allows selective fixup of individual interface sections instead of having to do the full scan_interfaces
SVN-Revision: 31543
Diffstat (limited to 'package/base-files-network/files')
-rwxr-xr-xpackage/base-files-network/files/lib/network/config.sh44
1 files changed, 25 insertions, 19 deletions
diff --git a/package/base-files-network/files/lib/network/config.sh b/package/base-files-network/files/lib/network/config.sh
index 5e8b059..8ba31a8 100755
--- a/package/base-files-network/files/lib/network/config.sh
+++ b/package/base-files-network/files/lib/network/config.sh
@@ -48,34 +48,40 @@ find_config() {
return 1;
}
-scan_interfaces() {
- local cfgfile="${1:-network}"
- interfaces=
- config_cb() {
- case "$1" in
- interface)
- config_set "$2" auto 1
- ;;
- esac
+fixup_interface() {
local iftype ifname device proto
- config_get iftype "$CONFIG_SECTION" TYPE
+ local __cfg="$1"
+
+ config_get iftype "$__cfg" TYPE
case "$iftype" in
interface)
- append interfaces "$CONFIG_SECTION"
- config_get proto "$CONFIG_SECTION" proto
- config_get iftype "$CONFIG_SECTION" type
- config_get ifname "$CONFIG_SECTION" ifname
- config_get device "$CONFIG_SECTION" device "$ifname"
- config_set "$CONFIG_SECTION" device "$device"
+ append interfaces "$__cfg"
+ config_get proto "$__cfg" proto
+ config_get iftype "$__cfg" type
+ config_get ifname "$__cfg" ifname
+ config_get device "$__cfg" device "$ifname"
+ config_set "$__cfg" device "$device"
case "$iftype" in
bridge)
- config_set "$CONFIG_SECTION" ifnames "$device"
- config_set "$CONFIG_SECTION" ifname br-"$CONFIG_SECTION"
+ config_set "$__cfg" ifnames "$device"
+ config_set "$__cfg" ifname br-"$CONFIG_SECTION"
;;
esac
- ( type "scan_$proto" ) >/dev/null 2>/dev/null && eval "scan_$proto '$CONFIG_SECTION'"
+ ( type "scan_$proto" ) >/dev/null 2>/dev/null && eval "scan_$proto '$__cfg'"
+ ;;
+ esac
+}
+
+scan_interfaces() {
+ local cfgfile="${1:-network}"
+ interfaces=
+ config_cb() {
+ case "$1" in
+ interface)
+ config_set "$2" auto 1
;;
esac
+ fixup_interface "$CONFIG_SECTION"
}
config_load "${cfgfile}"
}