mpc85xx: use image metadata
[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 . /lib/functions.sh
9
10 do_change_switch_name() {
11 local config="$1"
12 local option=$2
13 local oldname=$3
14 local newname=$4
15 local val
16
17 config_get val "$config" $option
18 [ "$val" != "$oldname" ] && return 0
19
20 uci_set network "$config" $option $newname
21 SWITCH_NAME_CHANGED=1
22
23 return 0
24 }
25
26 migrate_switch_name() {
27 local oldname=$1
28 local newname=$2
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 board=$(board_name)
44
45 case "$board" in
46 dir-825-c1|\
47 wzr-hp-g300nh2|\
48 tl-wdr4300|\
49 tl-wr1041n-v2|\
50 wrt160nl|\
51 ap121|\
52 ap121-mini|\
53 ap96|\
54 airrouter|\
55 dir-600-a1|\
56 dir-615-c1|\
57 dir-615-e1|\
58 dir-615-e4|\
59 ebr-2310-c1|\
60 ja76pf|\
61 rb-750|\
62 rb-751|\
63 tew-632brp|\
64 tew-712br|\
65 tl-mr3220|\
66 tl-mr3220-v2 |\
67 tl-mr3420|\
68 tl-wr741nd|\
69 tl-wr741nd-v4|\
70 tl-wr841n-v7|\
71 whr-g301n|\
72 whr-hp-g300n|\
73 whr-hp-gn|\
74 wzr-hp-ag300h|\
75 wzr-hp-g450h|\
76 z1|\
77 ew-dorin|\
78 ew-dorin-router)
79 migrate_switch_name "eth0" "switch0"
80 ;;
81
82 el-m150|\
83 rb-450)
84 migrate_switch_name "eth1" "switch0"
85 ;;
86
87 db120|\
88 rb-2011il|\
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