ar71xx: create even more network configs from the uci-defaults script
[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 aw-nr580 |\
83 bullet-m |\
84 eap7660d |\
85 rb-411 |\
86 tl-wa901nd-v2 |\
87 tl-wr703n |\
88 wp543)
89 set_interface_lan "eth0"
90 ;;
91
92 ap83 |\
93 jwap003 |\
94 pb42 |\
95 pb44 |\
96 routerstation)
97 set_interfaces_lan_wan "eth1" "eth0"
98 ;;
99
100 ap121 |\
101 ap121-mini |\
102 ap96 |\
103 dir-600-a1 |\
104 dir-615-c1 |\
105 ja76pf |\
106 rb750 |\
107 tew-632brp |\
108 tl-mr3220 |\
109 tl-mr3420 |\
110 tl-wr741nd |\
111 tl-wr741nd-v4 |\
112 whr-g301n |\
113 whr-hp-g300n |\
114 whr-hp-gn |\
115 wzr-hp-ag300h)
116 set_interfaces_lan_wan "eth0" "eth1"
117 add_switch "eth0" "1" "1"
118 add_switch_vlan "eth0" "1" "0 1 2 3 4"
119 ;;
120
121 *)
122 set_interfaces_lan_wan "eth0" "eth1"
123 ;;
124 esac
125
126 uci commit network
127
128 exit 0
This page took 0.048355 seconds and 5 git commands to generate.