feat: inject legacy API token during migration

This commit is contained in:
Zenaku 2026-09-21 15:25:04 +02:00
parent 32967b3658
commit 43f09f76bc

View file

@ -142,6 +142,15 @@ echo "$LEGACY_PRIVATE_KEY" > "$WG_SERVER_KEY"
echo "$LEGACY_PUBLIC_KEY" > "$WG_SERVER_PUB"
ok "Private key written to server keyfile."
# ─── INJECT API TOKEN ────────────────────────────────────────────────────────
sep
info "Injecting legacy API token..."
LEGACY_API_TOKEN=$(grep -E '^API_TOKEN=' "$BACKUP_DIR/legacy.env" | cut -d= -f2 | tr -d '[:space:]')
[ -z "$LEGACY_API_TOKEN" ] && warn "No legacy API token found, keeping generated one." || {
sed -i "s|^OPERATOR_API_TOKEN=.*|OPERATOR_API_TOKEN=$LEGACY_API_TOKEN|" "$OPERATOR_DIR/.env"
ok "API token injected from legacy."
}
# ─── START NEW WIREGUARD ──────────────────────────────────────────────────────
sep
info "Starting new WireGuard with legacy identity..."