summaryrefslogtreecommitdiff
path: root/target/linux/ramips/base-files
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-12-01 22:48:45 +0000
committerGabor Juhos <juhosg@openwrt.org>2011-12-01 22:48:45 +0000
commit569d8de6d6135b8a7591b93d460b00acd2661f3c (patch)
tree5082add187bb996f4d2b8bb678368932be926998 /target/linux/ramips/base-files
parent66c9a351dd722731b63047da8f8e0e78610de035 (diff)
downloadmtk-20170518-569d8de6d6135b8a7591b93d460b00acd2661f3c.zip
mtk-20170518-569d8de6d6135b8a7591b93d460b00acd2661f3c.tar.gz
mtk-20170518-569d8de6d6135b8a7591b93d460b00acd2661f3c.tar.bz2
ramips: simplify uci-defaults/network script
SVN-Revision: 29383
Diffstat (limited to 'target/linux/ramips/base-files')
-rwxr-xr-xtarget/linux/ramips/base-files/etc/uci-defaults/network63
1 files changed, 13 insertions, 50 deletions
diff --git a/target/linux/ramips/base-files/etc/uci-defaults/network b/target/linux/ramips/base-files/etc/uci-defaults/network
index 7baac0c..9d464cd 100755
--- a/target/linux/ramips/base-files/etc/uci-defaults/network
+++ b/target/linux/ramips/base-files/etc/uci-defaults/network
@@ -52,61 +52,17 @@ get_mac_nvram()
maccalc add "$mac_dirty" 0
}
-set_macs()
+set_interface_mac()
{
- local lan_mac="$1"
- local wan_mac="$2"
-
- echo "Setting LAN mac address to: $lan_mac" >&2
- echo "Setting WAN mac address to: $wan_mac" >&2
+ local iface="$1"
+ local mac="$2"
uci batch <<EOF
-set network.lan.macaddr='$lan_mac'
-set network.wan.macaddr='$wan_mac'
+set network.$iface.macaddr=""$mac"
commit network
EOF
}
-set_macs_only_lan()
-{
- local lan_mac="$1"
- local wan_mac
-
- wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
-
- set_macs "$lan_mac" "$wan_mac"
-}
-
-set_macs_only_lan_from_mtd()
-{
- local mtdname="$1"
- local seek="$2"
- local lan_mac
-
- lan_mac=$(get_mac_binary "$mtdname" "$seek")
- if [ -z $lan_mac ]; then
- echo "set_macs_only_lan_from_mtd: can't extract mac address from $part" >&2
- return
- fi
-
- set_macs_only_lan "$lan_mac"
-}
-
-set_macs_only_lan_from_nvram()
-{
- local mtdname="$1"
- local key="$2"
- local lan_mac
-
- lan_mac=$(get_mac_nvram "$mtdname" "$key")
- if [ -z $lan_mac ]; then
- echo "set_macs_only_lan_from_nvram: can't extract mac address from $part" >&2
- return
- fi
-
- set_macs_only_lan "$lan_mac"
-}
-
ramips_setup_interfaces()
{
local board="$1"
@@ -129,18 +85,25 @@ ramips_setup_interfaces()
ramips_setup_macs()
{
local board="$1"
+ local lan_mac=""
+ local wan_mac=""
case $board in
f5d8235-v2)
- set_macs_only_lan_from_mtd "u-boot" 262148
+ lan_mac=$(get_mac_nvram "u-boot" 262148)
+ wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
;;
argus-atp52b | \
b2c | \
nw718)
- set_macs_only_lan_from_mtd "factory" 4
+ lan_mac=$(get_mac_binary factory 4)
+ wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
;;
esac
+
+ [ -n $lan_mac ] && set_interface_mac lan $lan_mac
+ [ -n $wan_mac ] && set_interface_mac wan $wan_mac
}
board=$(ramips_board_name)