base-files: migrate old UCI network bridge ports syntax
authorRafał Miłecki <rafal@milecki.pl>
Sat, 15 May 2021 21:04:35 +0000 (23:04 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Tue, 18 May 2021 18:07:56 +0000 (20:07 +0200)
netifd has been recently patched to use more accurate "ports" option
instead of "ifname". This is a simple translation between two UCI
options.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
package/base-files/files/etc/uci-defaults/11_network-migrate-bridges [new file with mode: 0644]

diff --git a/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges b/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges
new file mode 100644 (file)
index 0000000..7456485
--- /dev/null
@@ -0,0 +1,23 @@
+. /lib/functions.sh
+
+migrate_ports() {
+       local config="$1"
+       local type ports ifname
+
+       config_get type "$config" type
+       [ "$type" != "bridge" ] && return
+
+       config_get ports "$config" ports
+       [ -n "$ports" ] && return
+
+       config_get ifname "$config" ifname
+       [ -z "$ifname" ] && return
+
+       for port in $ifname; do uci add_list network.$config.ports="$port"; done
+       uci delete network.$config.ifname
+}
+
+config_load network
+config_foreach migrate_ports device
+
+exit 1