Fresh pull from upstream
[librecmc/librecmc.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 tl-wdr4300|\
51 tl-wr1041n-v2|\
52 wrt160nl|\
53 ap121|\
54 ap121-mini|\
55 ap96|\
56 airrouter|\
57 dir-600-a1|\
58 dir-615-c1|\
59 dir-615-e1|\
60 dir-615-e4|\
61 ja76pf|\
62 rb-750|\
63 rb-751|\
64 tew-632brp|\
65 tew-712br|\
66 tl-mr3220|\
67 tl-mr3220-v2 |\
68 tl-mr3420|\
69 tl-wr741nd|\
70 tl-wr741nd-v4|\
71 tl-wr841n-v7|\
72 whr-g301n|\
73 whr-hp-g300n|\
74 whr-hp-gn|\
75 wzr-hp-ag300h|\
76 wzr-hp-g450h|\
77 z1|\
78 ew-dorin|\
79 ew-dorin-router)
80         migrate_switch_name "eth0" "switch0"
81         ;;
82
83 el-m150|\
84 rb-450)
85         migrate_switch_name "eth1" "switch0"
86         ;;
87
88 db120 |\
89 rb-2011l | \
90 rb-2011uas-2hnd)
91         migrate_switch_name "eth0" "switch0"
92         migrate_switch_name "eth1" "switch1"
93         ;;
94
95 dir-825-b1|\
96 tew-673gru|\
97 nbg460n_550n_550nh)
98         migrate_switch_name "rtl8366s" "switch0"
99         ;;
100
101 tl-wr1043nd)
102         migrate_switch_name "rtl8366rb" "switch0"
103         ;;
104
105 esac
106
107 exit 0