ar71xx: create RB-450G, RouterStation Pro 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_lan() {
17 local ifname=$1
18
19 uci batch <<EOF
20 set network.lan='interface'
21 set network.lan.ifname='$ifname'
22 set network.lan.type='bridge'
23 set network.lan.proto='static'
24 set network.lan.ipaddr='192.168.1.1'
25 set network.lan.netmask='255.255.255.0'
26 EOF
27 }
28
29 set_interface_wan() {
30 local ifname=$1
31
32 uci batch <<EOF
33 set network.wan='interface'
34 set network.wan.ifname='$ifname'
35 set network.wan.proto='dhcp'
36 EOF
37 }
38
39 set_interfaces_lan_wan() {
40 local lan_ifname=$1
41 local wan_ifname=$2
42
43 set_interface_lan "$lan_ifname"
44 set_interface_wan "$wan_ifname"
45 }
46
47 add_switch() {
48 local name=$1
49 local reset=$2
50 local enable=$3
51 uci batch <<EOF
52 add network switch
53 set network.@switch[-1].name='$name'
54 set network.@switch[-1].reset='$reset'
55 set network.@switch[-1].enable_vlan='$enable'
56 EOF
57 }
58
59 add_switch_vlan() {
60 local device=$1
61 local vlan=$2
62 local ports=$3
63 uci batch <<EOF
64 add network switch_vlan
65 set network.@switch_vlan[-1].device='$device'
66 set network.@switch_vlan[-1].vlan='$vlan'
67 set network.@switch_vlan[-1].ports='$ports'
68 EOF
69 }
70
71 [ -e /etc/config/network ] && exit 0
72
73 touch /etc/config/network
74
75 set_interface_loopback
76
77 . /lib/ar71xx.sh
78
79 board=$(ar71xx_board_name)
80
81 case "$board" in
82 rb-433 |\
83 rb-433u)
84 set_interfaces_lan_wan "eth1" "eth0"
85 add_switch "switch0" "1" "1"
86 add_switch_vlan "switch0" "1" "1 2 5"
87 ;;
88
89 rb-450g |\
90 routerstation-pro)
91 set_interfaces_lan_wan "eth1" "eth0"
92 add_switch "switch0" "1" "1"
93 add_switch_vlan "switch0" "1" "0 1 2 3 4"
94 ;;
95
96 aw-nr580 |\
97 bullet-m |\
98 eap7660d |\
99 rb-411 |\
100 tl-wa901nd-v2 |\
101 tl-wr703n |\
102 wp543)
103 set_interface_lan "eth0"
104 ;;
105
106 ap83 |\
107 jwap003 |\
108 pb42 |\
109 pb44 |\
110 routerstation)
111 set_interfaces_lan_wan "eth1" "eth0"
112 ;;
113
114 ap121 |\
115 ap121-mini |\
116 ap96 |\
117 dir-600-a1 |\
118 dir-615-c1 |\
119 ja76pf |\
120 rb750 |\
121 tew-632brp |\
122 tl-mr3220 |\
123 tl-mr3420 |\
124 tl-wr741nd |\
125 tl-wr741nd-v4 |\
126 whr-g301n |\
127 whr-hp-g300n |\
128 whr-hp-gn |\
129 wzr-hp-ag300h)
130 set_interfaces_lan_wan "eth0" "eth1"
131 add_switch "eth0" "1" "1"
132 add_switch_vlan "eth0" "1" "0 1 2 3 4"
133 ;;
134
135 *)
136 set_interfaces_lan_wan "eth0" "eth1"
137 ;;
138 esac
139
140 uci commit network
141
142 exit 0
This page took 0.056282 seconds and 5 git commands to generate.