diff options
author | Roman Yeryomin <roman@advem.lv> | 2014-03-11 00:54:50 +0200 |
---|---|---|
committer | Roman Yeryomin <roman@advem.lv> | 2014-03-11 00:54:50 +0200 |
commit | 68861cc62872ac7a2cf40acc70c4a8688660bc8e (patch) | |
tree | f98a1ee4a6024a2cc7769090455a4bbf095969cd /target/linux/realtek/base-files/etc | |
parent | d53bc6bfaf30d6180d4b2e18ea54409a4bafeebc (diff) |
Add preinit and uci-defaults scripts infrastructure. Generate network config automagically. Read lan/wan MAC addresses from MIB.
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/base-files/etc')
-rw-r--r-- | target/linux/realtek/base-files/etc/config/network | 16 | ||||
-rwxr-xr-x | target/linux/realtek/base-files/etc/uci-defaults/02_network | 59 |
2 files changed, 59 insertions, 16 deletions
diff --git a/target/linux/realtek/base-files/etc/config/network b/target/linux/realtek/base-files/etc/config/network deleted file mode 100644 index 19c85f8f9..000000000 --- a/target/linux/realtek/base-files/etc/config/network +++ /dev/null @@ -1,16 +0,0 @@ -config interface loopback - option ifname lo - option proto static - option ipaddr 127.0.0.1 - option netmask 255.0.0.0 - -config interface lan - option ifname "eth0 eth2 eth3 eth4" - option type bridge - option proto static - option ipaddr 192.168.2.1 - option netmask 255.255.255.0 - -config interface wan - option ifname eth1 - option proto dhcp diff --git a/target/linux/realtek/base-files/etc/uci-defaults/02_network b/target/linux/realtek/base-files/etc/uci-defaults/02_network new file mode 100755 index 000000000..d2d2e9829 --- /dev/null +++ b/target/linux/realtek/base-files/etc/uci-defaults/02_network @@ -0,0 +1,59 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/realtek.sh +. /lib/functions/uci-defaults.sh + +realtek_setup_interfaces() +{ + local board="$1" + + ucidef_set_interface_loopback + + case $board in + generic | \ + nprove | \ + nprove2) + ucidef_set_interfaces_lan_wan "eth0 eth2 eth3 eth4" "eth1" + ;; + + nprove3) + ucidef_set_interface_lan "eth0.1" + ;; + + *) + ucidef_set_interfaces_lan_wan "eth0" "eth1" + ;; + esac +} + +realtek_setup_macs() +{ + local board="$1" + local lan_mac="" + local wan_mac="" + + case $board in + generic | \ + nprove) + lan_mac=$(rtkmib --get mac0) + wan_mac=$(rtkmib --get mac1) + ;; + esac + + [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac +} + +[ -e /etc/config/network ] && exit 0 + +touch /etc/config/network + +board=$(realtek_board_name) + +realtek_setup_interfaces $board +realtek_setup_macs $board + +uci commit network + +exit 0 |