Developing lightweight computation at the DSG edge

switch_wdr.sh 1.52 KB
Newer Older
1
#!/bin/sh
2
# Stage = [birth|firstboot|anyboot|preconf|postconf]
3
4
STAGE="$1"

5
6
7
8
9
10
11
[ "$STAGE" == "birth" ] && {
	uci -q delete network.@switch[0]
	uci -q delete network.@switch_vlan[2]
	uci -q delete network.@switch_vlan[1]
	uci -q delete network.@switch_vlan[0]
}

12
13
14
15
16
17
[ "$STAGE" == "firstboot" ] && {

[ "$(uci -q get network.@switch[0].name)" == "eth0" ] && {
	echo "Switch already configured"
	exit 0
	}
18
19
20

echo "Configuring TPlink WDR switch [INET|LAN|LAN|LAN|MESH]"

21
uci -q delete network.@switch[0]
22
23
uci add network switch

24
25
26
uci -q delete network.@switch_vlan[2]
uci -q delete network.@switch_vlan[1]
uci -q delete network.@switch_vlan[0]
27
28
29
30
31
32
33
34
35
36
37

uci add network switch_vlan > /dev/null
uci add network switch_vlan > /dev/null
uci add network switch_vlan > /dev/null

uci set network.@switch[0]=switch
uci set network.@switch[0].name=eth0
uci set network.@switch[0].reset=1
uci set network.@switch[0].enable_vlan=1
uci set network.@switch_vlan[0]=switch_vlan
uci set network.@switch_vlan[0].device=eth0
38
39
uci set network.@switch_vlan[0].vlan=2
uci set network.@switch_vlan[0].vid=2
40
41
42
uci set network.@switch_vlan[0].ports="0t 2 3 4"
uci set network.@switch_vlan[1]=switch_vlan
uci set network.@switch_vlan[1].device=eth0
43
44
uci set network.@switch_vlan[1].vlan=3
uci set network.@switch_vlan[1].vid=3
45
46
47
uci set network.@switch_vlan[1].ports="0t 1"
uci set network.@switch_vlan[2]=switch_vlan
uci set network.@switch_vlan[2].device=eth0
48
uci set network.@switch_vlan[2].vlan=12
49
uci set network.@switch_vlan[2].vid=12
50
uci set network.@switch_vlan[2].ports="0t 5"
51
52
53

uci commit network
}