1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
7 [ -e /etc
/config
/network
] && {
17 append
batch "delete network.eth0.${1}${N}"
18 append
batch "set network.eth0_${n}=switch_vlan${N}"
19 append
batch "set network.eth0_${n}.device=eth0${N}"
20 append
batch "set network.eth0_${n}.vlan=${id}${N}"
21 append
batch "set network.eth0_${n}.ports='${2}'${N}"
36 logger
-t netconfig
"migrating switch config to new format ..."
37 echo "$batch${N}commit network" | uci
batch
46 if grep -E 'mtd0: 000(6|a)0000' /proc
/mtd
2>&- >&-; then
48 echo boardtype
=wgt634u
50 strings "$(find_mtd_part nvram)"
53 function p(cfgname, name) {
54 if (c[name] != "") print " option " cfgname " \"" c[name] "\""
57 function vlan(id, name) {
59 print "config switch_vlan eth0_" id
60 print " option device \"eth0\""
61 print " option vlan " id
62 print " option ports \"" c[name] "\""
67 function macinc(mac, maca, i, result) {
69 for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i]
70 if (++maca[6] > 0xff) {
74 for (i = 1; i <= 6; i++) {
75 if (i != 1) result = result ":"
76 result = result sprintf("%02x", maca[i])
83 c["lan_ifname"]="eth0.0"
84 c["wan_ifname"]="eth0.1"
85 c["vlan0ports"]="1 2 3 4 5*"
87 getline < "/proc/diag/model"
89 for (i = 0; i < 6; i++) {
90 if (mac_check != "") mac_check = mac_check ":"
91 mac_check = mac_check "[0-9a-fA-F][0-9a-fA-F]"
95 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") || ($1 ~ /macaddr/) {
100 if ((model == "ASUS WL-HDD") || (model == "ASUS WL-300g") || (model == "Linksys WAP54G V1")) {
102 c["lan_ifname"] = "eth1"
104 if (model == "ASUS WL-330gE") {
106 c["lan_ifname"] = "eth0"
110 if (model == "ASUS WL-500g") {
111 c["wan_ifname"] = "eth1"
112 c["lan_ifname"] = "eth0"
114 if (model == "ASUS WL-500g Premium V2") {
115 c["vlan0ports"] = "0 1 2 3 5*"
116 c["vlan1ports"] = "4 5"
118 if (model == "Dell TrueMobile 2300") {
119 c["lan_ifname"] = "eth0"
120 c["wan_ifname"] = "eth1"
121 c["vlan0ports"] = "0 1 2 3 4 5u"
124 if (model == "Dell TrueMobile 2300 v2") {
125 c["vlan0ports"] = "0 1 2 3 5*"
126 c["vlan1ports"] = "4 5"
128 if (nvram["boardtype"] == "bcm94710r4") {
130 c["lan_ifname"] = "eth0"
131 c["wan_ifname"] = "eth1"
133 if (nvram["boardtype"] == "wgt634u") {
134 c["vlan0ports"] = "0 1 2 3 5*"
135 c["vlan1ports"] = "4 5"
137 if (nvram["boardtype"] == "0x0467") {
138 c["vlan0ports"] = "0 1 2 3 5*"
139 c["vlan1ports"] = "4 5"
141 if ((nvram["boardtype"] == "0x042f") || (nvram["boardtype"] == "0x0472")) {
142 if (nvram["boardnum"] == "45") {
144 c["vlan0ports"] = "1 2 3 4 5*"
145 c["vlan1ports"] = "0 5"
148 c["vlan0ports"] = "0 1 2 3 4 5u"
150 c["lan_ifname"] = "eth0"
151 c["wan_ifname"] = "eth1"
153 # MAC addresses on 4704 tend to be screwed up. Add a workaround here
154 if (nvram["et0macaddr"] ~ mac_check) {
155 c["lan_macaddr"] = nvram["et0macaddr"]
156 c["wan_macaddr"] = macinc(c["lan_macaddr"])
160 # Buffalo WBR-B11 and Buffalo WBR-G54
161 if (nvram["boardtype"] == "bcm94710ap") {
162 c["vlan0ports"] = "0 1 2 3 4 5u"
164 c["lan_ifname"] = "eth0"
165 c["wan_ifname"] = "eth1"
167 if (nvram["boardtype"] == "0x478") {
168 # generic broadcom 4785 processor with 5397 switch?
169 c["vlan0ports"] = "1 2 3 4 8*"
170 c["vlan1ports"] = "0 8"
174 if ((nvram["boardnum"] == "2") || \
175 (nvram["boardnum"] == "1024")) {
176 c["lan_ifname"]="eth0"
181 if ((nvram["boardum"] == "2") && \
182 (nvram["GemtekPmonVer"] == "1")) {
183 c["lan_ifname"]="eth0"
188 # These are actually same as defaults above. For some reason this script applies
189 # Generic BCM94704 settings instead so we revert to proper settings here.
190 # Hopefully someone will fix this properly soon.
191 if (model == "ASUS WL-700gE") {
192 c["lan_ifname"]="eth0.0"
193 c["wan_ifname"]="eth0.1"
194 c["vlan0ports"]="1 2 3 4 5*"
195 c["vlan1ports"]="0 5"
198 if (model == "Motorola WR850G V2/V3") {
199 c["vlan0ports"]="0 1 2 3 5*"
200 c["vlan1ports"]="4 5"
202 if (model == "ASUS WL-500W") {
203 c["lan_ifname"] = "eth0"
204 c["wan_ifname"] = "eth1"
205 c["vlan0ports"] = "0 1 2 3 4 5u"
209 if (c["vlan0ports"] || c["vlan1ports"]) {
210 print "#### VLAN configuration "
211 print "config switch eth0"
212 print " option enable 1"
214 vlan(0, "vlan0ports")
215 vlan(1, "vlan1ports")
217 print "#### Loopback configuration"
218 print "config interface loopback"
219 print " option ifname \"lo\""
220 print " option proto static"
221 print " option ipaddr 127.0.0.1"
222 print " option netmask 255.0.0.0"
225 print "#### LAN configuration"
226 print "config interface lan"
227 print " option type bridge"
228 p("ifname", "lan_ifname")
229 p("macaddr", "lan_macaddr")
230 print " option proto static"
231 print " option ipaddr 192.168.1.1"
232 print " option netmask 255.255.255.0"
235 if (c["wan_ifname"]) {
236 print "#### WAN configuration"
237 print "config interface wan"
238 p("ifname", "wan_ifname")
239 p("macaddr", "wan_macaddr")
240 print " option proto dhcp"
242 print "#### WAN configuration (disabled)"
243 print "#config interface wan"
244 print "# option proto dhcp"
246 }' > /etc
/config
/network
This page took 0.063686 seconds and 5 git commands to generate.