ramips: fix mac addresses on the DIR-300/600 boards
[openwrt.git] / target / linux / ramips / base-files / etc / uci-defaults / network
1 #!/bin/sh
2
3 . /etc/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 if [ ! -x /usr/sbin/maccalc ]; then
8 echo "$0: maccalc not found!"
9 return
10 fi
11
12 ramips_setup_interfaces()
13 {
14 local board="$1"
15
16 ucidef_set_interface_loopback
17
18 case $board in
19 argus-atp52b | \
20 b2c | \
21 f5d8235-v2 | \
22 nw718)
23 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
24 ;;
25
26 rt-n15)
27 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28 ucidef_add_switch "rtl8366s" "1" "1"
29 ucidef_add_switch_vlan "rtl8366s" "1" "1 2 3 4 5t"
30 ucidef_add_switch_vlan "rtl8366s" "2" "0 5t"
31 ;;
32
33 *)
34 RT3X5X=`cat /proc/cpuinfo | grep RT3.5`
35 if [ -n "${RT3X5X}" ]; then
36 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
37 else
38 ucidef_set_interfaces_lan_wan "eth0" "eth1"
39 fi
40 ;;
41 esac
42 }
43
44 ramips_setup_macs()
45 {
46 local board="$1"
47 local lan_mac=""
48 local wan_mac=""
49
50 case $board in
51 f5d8235-v2)
52 lan_mac=$(ramips_get_mac_nvram "u-boot" 262148)
53 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
54 ;;
55
56 argus-atp52b | \
57 b2c | \
58 nw718 | \
59 rt-n15)
60 lan_mac=$(ramips_get_mac_binary factory 4)
61 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
62 ;;
63
64 dir-300-b1 |\
65 dir-300-b2 |\
66 dir-600-b1)
67 lan_mac=$(ramips_get_mac_binary devdata 16388)
68 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
69 ;;
70
71 nbg-419n)
72 lan_mac=$(ramips_get_mac_binary factory 4)
73 wan_mac=$(ramips_get_mac_binary factory 40)
74 ;;
75 esac
76
77 [ -n $lan_mac ] && ucidef_set_interface_macaddr lan $lan_mac
78 [ -n $wan_mac ] && ucidef_set_interface_macaddr wan $wan_mac
79 }
80
81 [ -e /etc/config/network ] && exit 0
82
83 touch /etc/config/network
84
85 board=$(ramips_board_name)
86
87 ramips_setup_interfaces $board
88 ramips_setup_macs $board
89
90 uci commit network
91
92 exit 0
This page took 0.043481 seconds and 5 git commands to generate.