#!/bin/sh

. /lib/functions.sh

migrate_stp()  {
	local section="$1"
	local type
	local stp

	stp="$(uci_get network "$section" "stp")"
	type="$(uci_get network "br_${section}" "type")"

	if [ -n "$stp" ]; then
		uci_remove "network" "$section" "stp"
	else
		return
	fi

	if [ "$stp" = "1" ] && [ "$type" = "bridge" ]; then
		uci_set "network" "br_${section}" "stp" "1"
	fi
}

config_load "network"
config_foreach migrate_stp "interface"
uci_commit "network"

exit 0
