1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
7 [ -e /etc
/config
/network
] && {
18 append
batch "delete network.eth0.${1}${N}"
19 append
batch "set network.eth0_${id}=switch_vlan${N}"
20 append
batch "set network.eth0_${id}.device=eth0${N}"
21 append
batch "set network.eth0_${id}.vlan=${id}${N}"
22 append
batch "set network.eth0_${id}.ports='${ports}'${N}"
37 logger
-t netconfig
"migrating switch config to new format ..."
38 echo "$batch${N}commit network" | uci
batch
47 if grep -E 'mtd0: 000(6|a)0000' /proc
/mtd
2>&- >&-; then
49 echo boardtype
=wgt634u
51 strings "$(find_mtd_part nvram)"
54 function p(cfgname, name) {
55 if (c[name] != "") print " option " cfgname " \"" c[name] "\""
58 function vlan(id, name) {
60 print "config switch_vlan eth0_" id
61 print " option device \"eth0\""
62 print " option vlan " id
63 print " option ports \"" c[name] "\""
68 function macinc(mac, maca, i, result) {
70 for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i]
71 if (++maca[6] > 0xff) {
75 for (i = 1; i <= 6; i++) {
76 if (i != 1) result = result ":"
77 result = result sprintf("%02x", maca[i])
84 c["lan_ifname"]="eth0.0"
85 c["wan_ifname"]="eth0.1"
86 c["vlan0ports"]="1 2 3 4 5"
88 getline < "/proc/diag/model"
90 for (i = 0; i < 6; i++) {
91 if (mac_check != "") mac_check = mac_check ":"
92 mac_check = mac_check "[0-9a-fA-F][0-9a-fA-F]"
96 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") || ($1 ~ /macaddr/) {
101 if ((model == "ASUS WL-HDD") || (model == "ASUS WL-300g") || (model == "Linksys WAP54G V1")) {
103 c["lan_ifname"] = "eth1"
105 if (model == "ASUS WL-330gE") {
107 c["lan_ifname"] = "eth0"
111 if ((model == "ASUS WL-500g") || (model == "Microsoft MN-700")) {
112 c["wan_ifname"] = "eth1"
113 c["lan_ifname"] = "eth0"
115 if (model == "ASUS WL-500g Premium V2") {
116 c["vlan0ports"] = "0 1 2 3 5"
117 c["vlan1ports"] = "4 5"
119 if (model == "Dell TrueMobile 2300") {
120 c["lan_ifname"] = "eth0"
121 c["wan_ifname"] = "eth1"
122 c["vlan0ports"] = "0 1 2 3 4 5u"
125 if (model == "Dell TrueMobile 2300 v2") {
126 c["vlan0ports"] = "0 1 2 3 5"
127 c["vlan1ports"] = "4 5"
129 if (nvram["boardtype"] == "bcm94710r4") {
131 c["lan_ifname"] = "eth0"
132 c["wan_ifname"] = "eth1"
134 if (nvram["boardtype"] == "wgt634u") {
135 c["vlan0ports"] = "0 1 2 3 5"
136 c["vlan1ports"] = "4 5"
138 if (nvram["boardtype"] == "0x0467") {
139 c["vlan0ports"] = "0 1 2 3 5"
140 c["vlan1ports"] = "4 5"
142 if ((nvram["boardtype"] == "0x042f") || (nvram["boardtype"] == "0x0472")) {
143 if (nvram["boardnum"] == "45") {
145 c["vlan0ports"] = "1 2 3 4 5"
146 c["vlan1ports"] = "0 5"
149 c["vlan0ports"] = "0 1 2 3 4 5u"
151 c["lan_ifname"] = "eth0"
152 c["wan_ifname"] = "eth1"
154 # MAC addresses on 4704 tend to be screwed up. Add a workaround here
155 if (nvram["et0macaddr"] ~ mac_check) {
156 c["lan_macaddr"] = nvram["et0macaddr"]
157 c["wan_macaddr"] = macinc(c["lan_macaddr"])
161 # Buffalo WBR-B11 and Buffalo WBR-G54
162 if (nvram["boardtype"] == "bcm94710ap") {
163 c["vlan0ports"] = "0 1 2 3 4 5u"
165 c["lan_ifname"] = "eth0"
166 c["wan_ifname"] = "eth1"
168 # generic broadcom 4705/4785 processor with 5397 switch?
169 # EXCEPT Linksys WRT300N V1.1
170 if ((nvram["boardtype"] == "0x478") && \
171 (model != "Linksys WRT300N V1.1")) {
172 c["vlan0ports"] = "1 2 3 4 8*"
173 c["vlan1ports"] = "0 8"
177 if ((nvram["boardnum"] == "2") || \
178 (nvram["boardnum"] == "1024")) {
179 c["lan_ifname"]="eth0"
184 if ((nvram["boardum"] == "2") && \
185 (nvram["GemtekPmonVer"] == "1")) {
186 c["lan_ifname"]="eth0"
191 # These are actually same as defaults above. For some reason this script applies
192 # Generic BCM94704 settings instead so we revert to proper settings here.
193 # Hopefully someone will fix this properly soon.
194 if (model == "ASUS WL-700gE") {
195 c["lan_ifname"]="eth0.0"
196 c["wan_ifname"]="eth0.1"
197 c["vlan0ports"]="1 2 3 4 5"
198 c["vlan1ports"]="0 5"
201 if (model == "Motorola WR850G V2/V3") {
202 c["vlan0ports"]="0 1 2 3 5"
203 c["vlan1ports"]="4 5"
205 if (model == "ASUS WL-500W") {
206 c["lan_ifname"] = "eth0"
207 c["wan_ifname"] = "eth1"
208 c["vlan0ports"] = "0 1 2 3 4 5u"
211 if (model == "OvisLink WL-1600GL") {
212 c["lan_ifname"] = "eth0.0"
213 c["wan_ifname"] = "eth0.1"
214 c["vlan0ports"] = "0 1 2 3 5"
215 c["vlan1ports"] = "4 5"
218 if (c["vlan0ports"] || c["vlan1ports"]) {
219 print "#### VLAN configuration "
220 print "config switch eth0"
221 print " option enable 1"
223 vlan(0, "vlan0ports")
224 vlan(1, "vlan1ports")
226 print "#### Loopback configuration"
227 print "config interface loopback"
228 print " option ifname \"lo\""
229 print " option proto static"
230 print " option ipaddr 127.0.0.1"
231 print " option netmask 255.0.0.0"
234 print "#### LAN configuration"
235 print "config interface lan"
236 print " option type bridge"
237 p("ifname", "lan_ifname")
238 p("macaddr", "lan_macaddr")
239 print " option proto static"
240 print " option ipaddr 192.168.1.1"
241 print " option netmask 255.255.255.0"
244 if (c["wan_ifname"]) {
245 print "#### WAN configuration"
246 print "config interface wan"
247 p("ifname", "wan_ifname")
248 p("macaddr", "wan_macaddr")
249 print " option proto dhcp"
251 print "#### WAN configuration (disabled)"
252 print "#config interface wan"
253 print "# option proto dhcp"
255 }' > /etc
/config
/network
This page took 0.06279 seconds and 5 git commands to generate.