mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 23:43:20 +02:00
confd: check for control-plane-protocol before migration
Refactor 0f9d429 to first check if the .cfg file has any routing
protocol active before converting the type's value.
This fixes a regression in the release cycle that otherwise would
cause a fresh startup-config, created from a plain factory-config
from v24.08, to be converted to an empty file.
Inspired by this fix, the same mitigation, albeit highyl unlikely,
has been applied to the v1.0 user shell type migration.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
# Migrate infix-shell-type:bash -> infix-system:bash
|
||||
|
||||
file=$1
|
||||
temp=$1.tmp
|
||||
|
||||
jq '.["ietf-system:system"].authentication.user |= map(.["infix-system:shell"] |= gsub("infix-shell-type:"; ""))' "$file" > "$temp"
|
||||
mv "$temp" "$file"
|
||||
temp=${file}.tmp
|
||||
|
||||
if jq -e '.["ietf-system:system"]?.authentication?.user? | length > 0' "$file" > /dev/null 2>&1; then
|
||||
jq '.["ietf-system:system"].authentication.user |= map(.["infix-system:shell"] |= gsub("infix-shell-type:"; ""))' "$file" > "$temp"
|
||||
mv "$temp" "$file"
|
||||
fi
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
#!/bin/sh
|
||||
# migrate ietf-routing-type => infix-routing-type
|
||||
file=$1
|
||||
temp=$1.tmp
|
||||
|
||||
jq '(.["ietf-routing:routing"]."control-plane-protocols"."control-plane-protocol"[] | select(.type == "ietf-ospf:ospfv2").type) |= "infix-routing:ospfv2"' "$file" > "$temp"
|
||||
jq '(.["ietf-routing:routing"]."control-plane-protocols"."control-plane-protocol"[] | select(.type == "static").type) |= "infix-routing:static"' "$temp" > "$file"
|
||||
migrate_routing_type()
|
||||
{
|
||||
file=$1
|
||||
match=$2
|
||||
replace=$3
|
||||
|
||||
if jq -e '.["ietf-routing:routing"]?."control-plane-protocols"?."control-plane-protocol"?[] | length > 0' "$file" > /dev/null 2>&1; then
|
||||
jq --arg match "${match}" --arg replace "${replace}" '
|
||||
(.["ietf-routing:routing"]."control-plane-protocols"."control-plane-protocol"[] |
|
||||
select(.type == $match).type) |= $replace' "${file}" > "${file}.tmp"
|
||||
mv "${file}.tmp" "${file}"
|
||||
fi
|
||||
}
|
||||
|
||||
migrate_routing_type "$1" "ietf-ospf:ospfv2" "infix-routing:ospfv2"
|
||||
migrate_routing_type "$1" "static" "infix-routing:static"
|
||||
|
||||
Reference in New Issue
Block a user