ar71xx: create PB92 network config from uci-defaults
[openwrt.git] / target / linux / ar71xx / base-files / etc / uci-defaults / network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011 OpenWrt.org
4 #
5
6 set_interface_loopback() {
7 uci batch <<EOF
8 set network.loopback='interface'
9 set network.loopback.ifname='lo'
10 set network.loopback.proto='static'
11 set network.loopback.ipaddr='127.0.0.1'
12 set network.loopback.netmask='255.0.0.0'
13 EOF
14 }
15
16 set_interface_raw() {
17 local cfg=$1
18 local ifname=$2
19
20 uci batch <<EOF
21 set network.$cfg='interface'
22 set network.$cfg.ifname='$ifname'
23 set network.$cfg.proto='none'
24 EOF
25 }
26
27 set_interface_lan() {
28 local ifname=$1
29
30 uci batch <<EOF
31 set network.lan='interface'
32 set network.lan.ifname='$ifname'
33 set network.lan.type='bridge'
34 set network.lan.proto='static'
35 set network.lan.ipaddr='192.168.1.1'
36 set network.lan.netmask='255.255.255.0'
37 EOF
38 }
39
40 set_interface_wan() {
41 local ifname=$1
42
43 uci batch <<EOF
44 set network.wan='interface'
45 set network.wan.ifname='$ifname'
46 set network.wan.proto='dhcp'
47 EOF
48 }
49
50 set_interfaces_lan_wan() {
51 local lan_ifname=$1
52 local wan_ifname=$2
53
54 set_interface_lan "$lan_ifname"
55 set_interface_wan "$wan_ifname"
56 }
57
58 add_switch() {
59 local name=$1
60 local reset=$2
61 local enable=$3
62 uci batch <<EOF
63 add network switch
64 set network.@switch[-1].name='$name'
65 set network.@switch[-1].reset='$reset'
66 set network.@switch[-1].enable_vlan='$enable'
67 EOF
68 }
69
70 add_switch_vlan() {
71 local device=$1
72 local vlan=$2
73 local ports=$3
74 uci batch <<EOF
75 add network switch_vlan
76 set network.@switch_vlan[-1].device='$device'
77 set network.@switch_vlan[-1].vlan='$vlan'
78 set network.@switch_vlan[-1].ports='$ports'
79 EOF
80 }
81
82 [ -e /etc/config/network ] && exit 0
83
84 touch /etc/config/network
85
86 set_interface_loopback
87
88 . /lib/ar71xx.sh
89
90 board=$(ar71xx_board_name)
91
92 case "$board" in
93 dir-825-b1)
94 set_interfaces_lan_wan "eth0.1" "eth1"
95 add_switch "rtl8366s" "1" "1"
96 add_switch_vlan "rtl8366s" "1" "0 1 2 3 5t"
97 ;;
98
99 rb-433 |\
100 rb-433u)
101 set_interfaces_lan_wan "eth1" "eth0"
102 add_switch "switch0" "1" "1"
103 add_switch_vlan "switch0" "1" "1 2 5"
104 ;;
105
106 rb-450)
107 set_interfaces_lan_wan "eth1" "eth0"
108 add_switch "eth1" "1" "1"
109 add_switch_vlan "eth1" "1" "0 1 2 3 5"
110 ;;
111
112 rb-450g |\
113 routerstation-pro)
114 set_interfaces_lan_wan "eth1" "eth0"
115 add_switch "switch0" "1" "1"
116 add_switch_vlan "switch0" "1" "0 1 2 3 4"
117 ;;
118
119 pb92)
120 set_interfaces_lan_wan "eth0.1" "eth0.2"
121 add_switch "eth0" "1" "1"
122 add_switch_vlan "eth0" "1" "0t 1 3 4 5"
123 add_switch_vlan "eth0" "2" "0t 2"
124 ;;
125
126 tl-wr841n-v1|\
127 tl-wr941nd)
128 set_interface_raw "eth" "eth0"
129 set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
130 ;;
131
132 aw-nr580 |\
133 bullet-m |\
134 eap7660d |\
135 rb-411 |\
136 tl-wa901nd-v2 |\
137 tl-wr703n |\
138 wp543)
139 set_interface_lan "eth0"
140 ;;
141
142 ap83 |\
143 jwap003 |\
144 pb42 |\
145 pb44 |\
146 routerstation)
147 set_interfaces_lan_wan "eth1" "eth0"
148 ;;
149
150 ap121 |\
151 ap121-mini |\
152 ap96 |\
153 dir-600-a1 |\
154 dir-615-c1 |\
155 ja76pf |\
156 rb750 |\
157 tew-632brp |\
158 tl-mr3220 |\
159 tl-mr3420 |\
160 tl-wr741nd |\
161 tl-wr741nd-v4 |\
162 whr-g301n |\
163 whr-hp-g300n |\
164 whr-hp-gn |\
165 wzr-hp-ag300h)
166 set_interfaces_lan_wan "eth0" "eth1"
167 add_switch "eth0" "1" "1"
168 add_switch_vlan "eth0" "1" "0 1 2 3 4"
169 ;;
170
171 *)
172 set_interfaces_lan_wan "eth0" "eth1"
173 ;;
174 esac
175
176 uci commit network
177
178 exit 0
This page took 0.066388 seconds and 5 git commands to generate.