source: trunk/target/linux/ar71xx/base-files/etc/uci-defaults/network @ 28829

Last change on this file since 28829 was 28829, checked in by juhosg, 5 years ago

ar71xx: create RB-493G network config from uci-defaults

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#!/bin/sh
2#
3# Copyright (C) 2011 OpenWrt.org
4#
5
6set_interface_loopback() {
7        uci batch <<EOF
8set network.loopback='interface'
9set network.loopback.ifname='lo'
10set network.loopback.proto='static'
11set network.loopback.ipaddr='127.0.0.1'
12set network.loopback.netmask='255.0.0.0'
13EOF
14}
15
16set_interface_raw() {
17        local cfg=$1
18        local ifname=$2
19
20        uci batch <<EOF
21set network.$cfg='interface'
22set network.$cfg.ifname='$ifname'
23set network.$cfg.proto='none'
24EOF
25}
26
27set_interface_lan() {
28        local ifname=$1
29
30        uci batch <<EOF
31set network.lan='interface'
32set network.lan.ifname='$ifname'
33set network.lan.type='bridge'
34set network.lan.proto='static'
35set network.lan.ipaddr='192.168.1.1'
36set network.lan.netmask='255.255.255.0'
37EOF
38}
39
40set_interface_wan() {
41        local ifname=$1
42
43        uci batch <<EOF
44set network.wan='interface'
45set network.wan.ifname='$ifname'
46set network.wan.proto='dhcp'
47EOF
48}
49
50set_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
58add_switch() {
59        local name=$1
60        local reset=$2
61        local enable=$3
62        uci batch <<EOF
63add network switch
64set network.@switch[-1].name='$name'
65set network.@switch[-1].reset='$reset'
66set network.@switch[-1].enable_vlan='$enable'
67EOF
68}
69
70add_switch_vlan() {
71        local device=$1
72        local vlan=$2
73        local ports=$3
74        uci batch <<EOF
75add network switch_vlan
76set network.@switch_vlan[-1].device='$device'
77set network.@switch_vlan[-1].vlan='$vlan'
78set network.@switch_vlan[-1].ports='$ports'
79EOF
80}
81
82[ -e /etc/config/network ] && exit 0
83
84touch /etc/config/network
85
86set_interface_loopback
87
88. /lib/ar71xx.sh
89
90board=$(ar71xx_board_name)
91
92case "$board" in
93dir-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
99rb-433 |\
100rb-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
106rb-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
112rb-450g |\
113routerstation-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
119rb-493g)
120        set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
121        add_switch "switch0" "1" "1"
122        add_switch_vlan "switch0" "1" "0 1 2 3 4"
123        add_switch "switch1" "1" "1"
124        add_switch_vlan "switch1" "1" "0t 1 2 3 4"
125        add_switch_vlan "switch1" "2" "0t 5"
126        ;;
127
128pb92)
129        set_interfaces_lan_wan "eth0.1" "eth0.2"
130        add_switch "eth0" "1" "1"
131        add_switch_vlan "eth0" "1" "0t 1 3 4 5"
132        add_switch_vlan "eth0" "2" "0t 2"
133        ;;
134
135tl-wr1043nd)
136        set_interfaces_lan_wan "eth0.1" "eth0.2"
137        add_switch "rtl8366rb" "1" "1"
138        add_switch_vlan "rtl8366rb" "1" "1 2 3 4 5t"
139        add_switch_vlan "rtl8366rb" "2" "0 5t"
140        ;;
141
142tl-wr841n-v1|\
143tl-wr941nd)
144        set_interface_raw "eth" "eth0"
145        set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
146        ;;
147
148wrt160nl)
149        set_interfaces_lan_wan "eth0" "eth1"
150        add_switch "eth0" "1" "1"
151        add_switch_vlan "eth0" "1" "0 1 2 3 4 5"
152        ;;
153
154aw-nr580 |\
155bullet-m |\
156eap7660d |\
157rb-411 |\
158tl-wa901nd-v2 |\
159tl-wr703n |\
160wp543)
161        set_interface_lan "eth0"
162        ;;
163
164ap83 |\
165jwap003 |\
166pb42 |\
167pb44 |\
168routerstation)
169        set_interfaces_lan_wan "eth1" "eth0"
170        ;;
171
172ap121 |\
173ap121-mini |\
174ap96 |\
175dir-600-a1 |\
176dir-615-c1 |\
177ja76pf |\
178rb750 |\
179tew-632brp |\
180tl-mr3220 |\
181tl-mr3420 |\
182tl-wr741nd |\
183tl-wr741nd-v4 |\
184whr-g301n |\
185whr-hp-g300n |\
186whr-hp-gn |\
187wzr-hp-ag300h)
188        set_interfaces_lan_wan "eth0" "eth1"
189        add_switch "eth0" "1" "1"
190        add_switch_vlan "eth0" "1" "0 1 2 3 4"
191        ;;
192
193*)
194        set_interfaces_lan_wan "eth0" "eth1"
195        ;;
196esac
197
198uci commit network
199
200exit 0
Note: See TracBrowser for help on using the repository browser.