CC: ar71xx: Fix WAN port location on EnGenius ESR1750 and EPG5000.
[15.05/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-e1|\
62 dir-615-e4|\
63 ja76pf|\
64 mr-12|\
65 mr-16|\
66 rb-750|\
67 rb-751|\
68 tew-632brp|\
69 tew-712br|\
70 tl-mr3220|\
71 tl-mr3220-v2 |\
72 tl-mr3420|\
73 tl-wr741nd|\
74 tl-wr741nd-v4|\
75 tl-wr841n-v7|\
76 whr-g301n|\
77 whr-hp-g300n|\
78 whr-hp-gn|\
79 wzr-hp-ag300h|\
80 wzr-hp-g450h|\
81 ew-dorin|\
82 ew-dorin-router)
83         migrate_switch_name "eth0" "switch0"
84         ;;
85
86 el-m150|\
87 rb-450)
88         migrate_switch_name "eth1" "switch0"
89         ;;
90
91 db120 |\
92 rb-2011l | \
93 rb-2011uas-2hnd)
94         migrate_switch_name "eth0" "switch0"
95         migrate_switch_name "eth1" "switch1"
96         ;;
97
98 dir-825-b1|\
99 tew-673gru|\
100 nbg460n_550n_550nh)
101         migrate_switch_name "rtl8366s" "switch0"
102         ;;
103
104 tl-wr1043nd)
105         migrate_switch_name "rtl8366rb" "switch0"
106         ;;
107
108 esac
109
110 exit 0