ar71xx: rework changes from r35840
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / uci-defaults / 03_network-switchX-migration
1 #!/bin/sh
2 #
3 # Copyright (C) 2013 OpenWrt.org
4 #
5
6 SWITCH_NAME_CHANGED=
7
8 do_change_switch_name() {
9 local config="$1"
10 local option=$2
11 local oldname=$3
12 local newname=$4
13 local val
14
15 config_get val "$config" $option
16 [ "$val" != "$oldname" ] && return 0
17
18 uci_set network "$config" $option $newname
19 SWITCH_NAME_CHANGED=1
20
21 return 0
22 }
23
24 migrate_switch_name() {
25 local oldname=$1
26 local newname=$2
27
28 . /lib/functions.sh
29
30 config_load network
31
32 logger -t migrate-switchX "Updating switch names in network configuration"
33
34 config_foreach do_change_switch_name switch name $oldname $newname
35 config_foreach do_change_switch_name switch_vlan device $oldname $newname
36
37 [ "$SWITCH_NAME_CHANGED" == "1" ] && {
38 logger -t migrate-switchX "Switch names updated, saving network configuration"
39 uci commit network
40 }
41 }
42
43 . /lib/ar71xx.sh
44
45 board=$(ar71xx_board_name)
46
47 case "$board" in
48 dir-825-c1|\
49 wzr-hp-g300nh2|\
50 pb92|\
51 ap113|\
52 tl-wdr4300|\
53 tl-wr1041n-v2|\
54 wrt160nl|\
55 ap121|\
56 ap121-mini|\
57 ap96|\
58 airrouter|\
59 dir-600-a1|\
60 dir-615-c1|\
61 dir-615-e4|\
62 ja76pf|\
63 rb-750|\
64 rb-751|\
65 tew-632brp|\
66 tew-712br|\
67 tl-mr3220|\
68 tl-mr3220-v2 |\
69 tl-mr3420|\
70 tl-wr741nd|\
71 tl-wr741nd-v4|\
72 tl-wr841n-v7|\
73 whr-g301n|\
74 whr-hp-g300n|\
75 whr-hp-gn|\
76 wzr-hp-ag300h|\
77 wzr-hp-g450h|\
78 ew-dorin|\
79 ew-dorin-router)
80 migrate_switch_name "eth0" "switch0"
81 ;;
82
83 rb-450)
84 migrate_switch_name "eth1" "switch0"
85 ;;
86
87 db120 |\
88 rb-2011l | \
89 rb-2011uas-2hnd)
90 migrate_switch_name "eth0" "switch0"
91 migrate_switch_name "eth1" "switch1"
92 ;;
93
94 dir-825-b1|\
95 tew-673gru|\
96 nbg460n_550n_550nh)
97 migrate_switch_name "rtl8366s" "switch0"
98 ;;
99
100 tl-wr1043nd)
101 migrate_switch_name "rtl8366rb" "switch0"
102 ;;
103
104 esac
105
106 exit 0