targets: files in uci-defaults do not need to be executables
[openwrt.git] / target / linux / ar71xx / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011 OpenWrt.org
4 #
5
6 [ -e /etc/config/network ] && exit 0
7
8 touch /etc/config/network
9
10 . /lib/functions/uci-defaults.sh
11 . /lib/ar71xx.sh
12
13 ucidef_set_interface_loopback
14
15 board=$(ar71xx_board_name)
16
17 case "$board" in
18 all0315n |\
19 all0258n |\
20 ja76pf2|\
21 ubnt-unifi-outdoor)
22         ucidef_set_interface_lan "eth0 eth1"
23         ;;
24
25 ap132 |\
26 wlr8100)
27         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28         ucidef_add_switch "switch0" "1" "1"
29         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
30         ucidef_add_switch_vlan "switch0" "2" "0t 1"
31         ;;
32
33 esr1750)
34         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
35         ucidef_add_switch "switch0" "1" "1"
36         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
37         ucidef_add_switch_vlan "switch0" "2" "0t 1"
38         ;;
39
40 ap136-010)
41         ucidef_set_interfaces_lan_wan "eth0" "eth1"
42         ucidef_add_switch "switch0" "1" "1"
43         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
44         ucidef_add_switch_vlan "switch0" "2" "5 6"
45         ;;
46
47 ap136-020 |\
48 ap135-020 |\
49 tl-wr1043nd-v2 |\
50 wzr-450hp2)
51         ucidef_set_interfaces_lan_wan "eth1" "eth0"
52         ucidef_add_switch "switch0" "1" "1"
53         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
54         ucidef_add_switch_vlan "switch0" "2" "5 6"
55         ;;
56
57 archer-c5 |\
58 archer-c7 |\
59 tl-wdr4900-v2)
60         ucidef_set_interfaces_lan_wan "eth1" "eth0"
61         ucidef_add_switch "switch0" "1" "1"
62         ucidef_add_switch_vlan "switch0" "1" "0 2 3 4 5"
63         ucidef_add_switch_vlan "switch0" "2" "1 6"
64         ;;
65
66 cpe510)
67         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
68         ucidef_add_switch "switch0" "1" "1"
69         ucidef_add_switch_vlan "switch0" "1" "0t 5"
70         ucidef_add_switch_vlan "switch0" "2" "0t 4"
71         ;;
72
73 db120 |\
74 rb-2011l | \
75 rb-2011uas |\
76 rb-2011uias |\
77 rb-2011uas-2hnd|\
78 rb-2011uias-2hnd)
79         ucidef_set_interfaces_lan_wan "eth0.1 eth1" "eth0.2"
80         ucidef_add_switch "switch0" "1" "1"
81         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
82         ucidef_add_switch_vlan "switch0" "2" "0t 1"
83         ucidef_add_switch "switch1" "1" "1"
84         ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 4 5"
85
86         case "$board" in
87         rb-2011uas* | rb-2011uias | rb-2011uias-2hnd)
88                 ucidef_set_interface_raw "sfp" "eth0.3"
89                 ucidef_add_switch_vlan "switch0" "3" "0t 6"
90                 ;;
91         esac
92         ;;
93
94 dir-825-b1|\
95 tew-673gru)
96         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
97         ucidef_add_switch "switch0" "1" "1"
98         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
99         ;;
100
101 f9k1115v2)
102         ucidef_set_interfaces_lan_wan "eth1" "eth0"
103         ucidef_add_switch "switch0" "1" "1"
104         ucidef_add_switch_vlan "switch0" "1" "2 3 4 5 6"
105         ucidef_add_switch_vlan "switch0" "2" "0 1"
106         ;;
107
108 nbg460n_550n_550nh)
109         ucidef_set_interfaces_lan_wan "eth0" "eth1"
110         ucidef_add_switch "switch0" "1" "1"
111         ucidef_add_switch_vlan "switch0" "0" "0 1 2 3 5"
112         ;;
113
114 nbg6716)
115         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
116         ucidef_add_switch "switch0" "1" "1"
117         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
118         ucidef_add_switch_vlan "switch0" "2" "5 6"
119         ;;
120
121 rb-433 |\
122 rb-433u)
123         ucidef_set_interfaces_lan_wan "eth1" "eth0"
124         ucidef_add_switch "switch0" "1" "1"
125         ucidef_add_switch_vlan "switch0" "1" "1 2 5"
126         ;;
127
128 rb-435g)
129         ucidef_set_interfaces_lan_wan "eth1" "eth0"
130         ucidef_add_switch "switch0" "1" "1"
131         ucidef_add_switch_vlan "switch0" "1" "0 1 2"
132         ;;
133
134 rb-450)
135         ucidef_set_interfaces_lan_wan "eth1" "eth0"
136         ucidef_add_switch "switch0" "1" "1"
137         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5"
138         ;;
139
140 rb-450g |\
141 routerstation-pro)
142         ucidef_set_interfaces_lan_wan "eth1" "eth0"
143         ucidef_add_switch "switch0" "1" "1"
144         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
145         ;;
146
147 ap136 |\
148 rb-750gl |\
149 rb-751g |\
150 rb-951g-2hnd |\
151 wzr-hp-g450h)
152         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
153         ucidef_add_switch "switch0" "1" "1"
154         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
155         ucidef_add_switch_vlan "switch0" "2" "0t 1"
156         ;;
157
158 rb-951ui-2hnd)
159         ucidef_set_interfaces_lan_wan "eth1" "eth0"
160         ;;
161
162 rb-493g)
163         ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
164         ucidef_add_switch "switch0" "1" "1"
165         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
166         ucidef_add_switch "switch1" "1" "1"
167         ucidef_add_switch_vlan "switch1" "1" "0t 1 2 3 4"
168         ucidef_add_switch_vlan "switch1" "2" "0t 5"
169         ;;
170
171 wzr-hp-g300nh2 |\
172 pb92 |\
173 ap113)
174         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
175         ucidef_add_switch "switch0" "1" "1"
176         ucidef_add_switch_vlan "switch0" "1" "0t 1 3 4 5"
177         ucidef_add_switch_vlan "switch0" "2" "0t 2"
178         ;;
179
180 el-m150)
181         ucidef_set_interfaces_lan_wan "eth1" "eth0"
182         ucidef_add_switch "switch0" "1" "1"
183         ucidef_add_switch_vlan "switch0" "1" "0 1 3"
184         ;;
185
186 el-mini)
187         ucidef_set_interface_lan "eth0"
188         ;;
189
190 tl-wdr4300|\
191 tl-wr1041n-v2)
192         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
193         ucidef_add_switch "switch0" "1" "1"
194         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
195         ucidef_add_switch_vlan "switch0" "2" "0t 1"
196         ;;
197
198 tl-wr1043nd)
199         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
200         ucidef_add_switch "switch0" "1" "1"
201         ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
202         ucidef_add_switch_vlan "switch0" "2" "0 5t"
203         ;;
204
205 tl-wr2543n)
206         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
207         ucidef_add_switch "switch0" "1" "1"
208         ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
209         ucidef_add_switch_vlan "switch0" "2" "0 9t"
210         ;;
211
212 tl-wr841n-v1|\
213 tl-wr941nd)
214         ucidef_set_interface_raw "eth" "eth0"
215         ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
216         ;;
217
218 r6100 |\
219 smart-300 |\
220 tl-mr3420-v2 |\
221 tl-wr841n-v8 |\
222 tl-wr842n-v2 |\
223 tl-wr941nd-v5 |\
224 wnr2000-v3 |\
225 wnr2000-v4 |\
226 wnr2200 |\
227 wnr612-v2 |\
228 wnr1000-v2)
229         ucidef_set_interfaces_lan_wan "eth1" "eth0"
230         ucidef_add_switch "switch0" "1" "1"
231         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
232         ;;
233
234 uap-pro)
235         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
236         ucidef_add_switch "switch0" "1" "1"
237         ucidef_add_switch_vlan "switch0" "1" "0t 1"
238         ucidef_add_switch_vlan "switch0" "2" "0t 2"
239         ;;
240
241 nanostation-m-xw)
242         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
243         ucidef_add_switch "switch0" "1" "1"
244         ucidef_add_switch_vlan "switch0" "1" "0t 5"
245         ucidef_add_switch_vlan "switch0" "2" "0t 1"
246         ;;
247
248 wrt160nl)
249         ucidef_set_interfaces_lan_wan "eth0" "eth1"
250         ucidef_add_switch "switch0" "1" "1"
251         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 5"
252         ;;
253
254 wzr-hp-g300nh)
255         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
256         ucidef_add_switch "switch0" "1" "1"
257         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
258         ;;
259
260 dgl-5500-a1 |\
261 dir-825-c1)
262         local mac
263         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
264         ucidef_add_switch "switch0" "1" "1"
265         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
266         ucidef_add_switch_vlan "switch0" "2" "0t 5"
267         mac=$(mtd_get_mac_ascii nvram "wan_mac")
268         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
269         ;;
270
271 mynet-n750)
272         local mac
273         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
274         ucidef_add_switch "switch0" "1" "1"
275         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
276         ucidef_add_switch_vlan "switch0" "2" "0t 5"
277         mac=$(mtd_get_mac_ascii devdata "wanmac")
278         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
279         ;;
280
281 dhp-1565-a1 |\
282 dir-835-a1 |\
283 wndr3700v4 | \
284 wndr4300)
285         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
286         ucidef_add_switch "switch0" "1" "1"
287         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
288         ucidef_add_switch_vlan "switch0" "2" "0t 5"
289         mac_lan=$(mtd_get_mac_binary caldata 0)
290         [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
291         mac_wan=$(mtd_get_mac_binary caldata 6)
292         [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
293         ;;
294
295 esr900)
296         local mac
297         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
298         ucidef_add_switch "switch0" "1" "1"
299         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
300         ucidef_add_switch_vlan "switch0" "2" "0t 5"
301         mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
302         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
303         ;;
304
305 all0305 |\
306 aw-nr580 |\
307 bullet-m |\
308 cap4200ag |\
309 eap300v2 |\
310 eap7660d |\
311 loco-m-xw |\
312 mr600 |\
313 mr600v2 |\
314 mr900 |\
315 mr900v2 |\
316 rb-411 |\
317 rb-911g-2hpnd |\
318 rb-911g-5hpnd |\
319 rb-912uag-2hpnd |\
320 rb-912uag-5hpnd |\
321 rb-sxt2n |\
322 rb-sxt5n |\
323 tl-mr10u |\
324 tl-mr11u |\
325 tl-mr13u |\
326 tl-mr3020 |\
327 tl-mr3040 |\
328 tl-mr3040-v2 |\
329 tl-wa701nd-v2 |\
330 tl-wa750re |\
331 tl-wa850re |\
332 tl-wa830re-v2 |\
333 tl-wa801nd-v2 |\
334 tl-wa901nd |\
335 tl-wa901nd-v2 |\
336 tl-wa901nd-v3 |\
337 tl-wr703n |\
338 tube2h |\
339 wndap360 |\
340 mynet-rext |\
341 wp543)
342         ucidef_set_interface_lan "eth0"
343         ;;
344
345 dir-505-a1)
346         ucidef_set_interface_lan "eth1"
347         ;;
348
349 alfa-ap96 |\
350 alfa-nx |\
351 ap83 |\
352 gl-inet |\
353 jwap003 |\
354 pb42 |\
355 pb44 |\
356 routerstation|\
357 tl-wr710n |\
358 tl-wr720n-v3|\
359 wpe72)
360         ucidef_set_interfaces_lan_wan "eth1" "eth0"
361         ;;
362
363 ap121 |\
364 ap121-mini |\
365 ap96 |\
366 airrouter |\
367 dir-600-a1 |\
368 dir-615-c1 |\
369 dir-615-e1 |\
370 dir-615-e4 |\
371 hiwifi-hc6361 |\
372 ja76pf |\
373 mynet-n600 |\
374 oolite |\
375 qihoo-c301 |\
376 rb-750 |\
377 rb-751 |\
378 tew-632brp |\
379 tew-712br |\
380 tl-mr3220 |\
381 tl-mr3220-v2 |\
382 tl-mr3420 |\
383 tl-wdr3500 |\
384 tl-wr741nd |\
385 tl-wr741nd-v4 |\
386 tl-wr841n-v7 |\
387 tl-wr841n-v9 |\
388 whr-g301n |\
389 whr-hp-g300n |\
390 whr-hp-gn |\
391 wzr-hp-ag300h)
392         ucidef_set_interfaces_lan_wan "eth0" "eth1"
393         ucidef_add_switch "switch0" "1" "1"
394         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
395         ;;
396
397 wzr-hp-g450h)
398         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
399         ucidef_add_switch "switch0" "1" "1"
400         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
401         ucidef_add_switch_vlan "switch0" "2" "0t 1"
402         ;;
403
404 ew-dorin)
405         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
406         ucidef_add_switch "switch0" "1" "1"
407         ucidef_add_switch_vlan "switch0" "1" "0t 1 2"
408         ucidef_add_switch_vlan "switch0" "2" "0t 3"
409         ;;
410
411 ew-dorin-router)
412         ucidef_set_interfaces_lan_wan "eth0" "eth1"
413         ucidef_add_switch "switch0" "1" "1"
414         ucidef_add_switch_vlan "switch0" "1" "0 2 3"
415         ;;
416
417 wndr3700)
418         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
419         ucidef_add_switch "switch0" "1" "1"
420         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
421         # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
422         uci set network.@switch[-1].blinkrate='2'
423
424         ucidef_add_switch_port "switch0" "1"
425         # Port 1 controls the GREEN configuration of LEDs for
426         # the switch and the section does not correspond to a real
427         # switch port.
428         #
429         # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
430         # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
431         # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
432         # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
433         # 14: Link (master); 15: separate register
434         uci set network.@switch_port[-1].led='6'
435
436         ucidef_add_switch_port "switch0" "2"
437         # Port 2 controls the ORANGE configuration of LEDs for
438         # the switch and the section does not correspond to a real
439         # switch port.
440         #
441         # See the key above for switch port 1 for the meaning of the
442         # 'led' setting below.
443         uci set network.@switch_port[-1].led='9'
444
445         ucidef_add_switch_port "switch0" "5"
446         # Port 5 controls the configuration of the WAN LED and the
447         # section does not correspond to a real switch port.
448         #
449         # To toggle the use of green or orange LEDs for the WAN port,
450         # see the LED setting for wndr3700:green:wan in /etc/config/system.
451         #
452         # See the key above for switch port 1 for the meaning of the
453         # 'led' setting below.
454         uci set network.@switch_port[-1].led='2'
455         ;;
456
457 *)
458         ucidef_set_interfaces_lan_wan "eth0" "eth1"
459         ;;
460 esac
461
462 uci commit network
463
464 exit 0