layer3-config: Add DSA migration script for migrated devices
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
Because of to the switch from swconfig to DSA, the switchport names have to be migrated for a few devices. Due to past migrations, we already have developed a migration script for that. Duplicate and adjust the script for the newly migrated devices. While at it, rename the old script to reflect the configuration version bump. Fixes: #301 Signed-off-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
parent
6586cc8944
commit
da0a853e69
@ -0,0 +1,76 @@
|
||||
## this script migrates configs from version 2 to 3.
|
||||
##
|
||||
## with version 2 the switchport names of some devices changed
|
||||
## due to the switch to DSA
|
||||
|
||||
|
||||
BOARD="$(uci get board.model.name)"
|
||||
|
||||
# only migrate appropriate config versions
|
||||
[ "$(uci -q get gateway.meta.config_version)" = "2" ] || exit 1
|
||||
|
||||
translate_ports() {
|
||||
local vlan="$1"
|
||||
local oldports="$(uci -q get gateway.$vlan.ports)"
|
||||
local newports
|
||||
|
||||
local name
|
||||
local tag
|
||||
|
||||
for port in $oldports; do
|
||||
# generate new tagged/untagged syntax
|
||||
if [ -z "${port##*t}" ]; then
|
||||
# port is tagged
|
||||
tag=":t"
|
||||
else
|
||||
# port is untagged
|
||||
tag=":*"
|
||||
fi
|
||||
|
||||
# generate new name
|
||||
case "$BOARD" in
|
||||
avm,fritzbox-4040)
|
||||
case "${port%%t}" in
|
||||
1) name="lan1" ;;
|
||||
2) name="lan2" ;;
|
||||
3) name="lan3" ;;
|
||||
4) name="lan4" ;;
|
||||
5) name="wan" ;;
|
||||
*) name="" ;;
|
||||
esac
|
||||
;;
|
||||
tplink,tl-wdr4900-v1)
|
||||
case "${port%%t}" in
|
||||
1) name="wan" ;;
|
||||
2) name="lan1" ;;
|
||||
3) name="lan2" ;;
|
||||
4) name="lan3" ;;
|
||||
5) name="lan4" ;;
|
||||
*) name="" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# catch empty name (invalid entry or old cpuport)
|
||||
[ -z "$name" ] && continue
|
||||
|
||||
# assemble new port name
|
||||
newports="$newports ${name}${tag}"
|
||||
done
|
||||
|
||||
# cleanup unnecessary spaces
|
||||
newports=$(echo "$newports" | xargs)
|
||||
|
||||
uci set gateway.$vlan.ports="$newports"
|
||||
}
|
||||
|
||||
case "$BOARD" in
|
||||
avm,fritzbox-4040|\
|
||||
tplink,tl-wdr4900-v1)
|
||||
config_load gateway
|
||||
config_foreach translate_ports vlan
|
||||
;;
|
||||
esac
|
||||
|
||||
uci set gateway.meta.config_version='3'
|
||||
uci commit gateway
|
Loading…
Reference in New Issue
Block a user