Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
86 lines
3.0 KiB
Bash
Executable File
86 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Start any stopped Proxmox containers that back E2E endpoints (502 fixes).
|
|
# Uses SSH to Proxmox hosts and pct start for containers that are stopped.
|
|
#
|
|
# Usage: ./scripts/maintenance/start-stopped-containers-via-ssh.sh [--dry-run]
|
|
# Env: PROXMOX_HOST_ML110 (default 192.168.11.10), PROXMOX_HOST_R630_01 (default 192.168.11.11)
|
|
# SSH to root@host; ensure key-based auth or use ssh-agent.
|
|
#
|
|
# VMIDs: DBIS (10130 frontend, 10150 api primary, 10151 api secondary) + optional 10100,10101,10120;
|
|
# RPC core 2101. Layout: 101xx on ML110 by default (create-dbis-core), 2101 on r630-01.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
[[ -f "${PROJECT_ROOT}/scripts/lib/load-project-env.sh" ]] && source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh" 2>/dev/null || true
|
|
|
|
DRY_RUN=false
|
|
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true
|
|
|
|
PROXMOX_ML110="${PROXMOX_HOST_ML110:-${PROXMOX_HOST:-192.168.11.10}}"
|
|
PROXMOX_R630_01="${PROXMOX_HOST_R630_01:-192.168.11.11}"
|
|
|
|
# DBIS Core containers (often on ml110)
|
|
VMIDS_DBIS="10130 10150 10151 10100 10101 10120"
|
|
# RPC core (r630-01 per ALL_VMIDS)
|
|
VMIDS_RPC="2101"
|
|
|
|
log_info() { echo -e "\033[0;34m[INFO]\033[0m $1"; }
|
|
log_ok() { echo -e "\033[0;32m[✓]\033[0m $1"; }
|
|
log_warn() { echo -e "\033[0;33m[⚠]\033[0m $1"; }
|
|
log_err() { echo -e "\033[0;31m[✗]\033[0m $1"; }
|
|
|
|
run_ssh() {
|
|
local host="$1"
|
|
shift
|
|
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@"$host" "$@"
|
|
}
|
|
|
|
start_stopped_on_host() {
|
|
local host="$1"
|
|
local vmids_list="$2"
|
|
local label="$3"
|
|
log_info "Host $host ($label): checking VMIDs $vmids_list"
|
|
if ! run_ssh "$host" "echo OK" &>/dev/null; then
|
|
log_warn "Cannot SSH to $host; skipping."
|
|
return 0
|
|
fi
|
|
for vmid in $vmids_list; do
|
|
local status
|
|
status=$(run_ssh "$host" "pct status $vmid 2>/dev/null | awk '{print \$2}'" 2>/dev/null || echo "missing")
|
|
if [[ "$status" == "missing" || -z "$status" ]]; then
|
|
log_info " VMID $vmid: not on this host or unknown, skip"
|
|
continue
|
|
fi
|
|
if [[ "$status" == "running" ]]; then
|
|
log_ok " VMID $vmid: already running"
|
|
continue
|
|
fi
|
|
if [[ "$DRY_RUN" == true ]]; then
|
|
log_info " VMID $vmid: would run pct start $vmid (current: $status)"
|
|
continue
|
|
fi
|
|
log_info " VMID $vmid: starting (was $status)..."
|
|
if run_ssh "$host" "pct start $vmid" 2>/dev/null; then
|
|
log_ok " VMID $vmid: started"
|
|
else
|
|
log_err " VMID $vmid: start failed"
|
|
fi
|
|
done
|
|
}
|
|
|
|
echo ""
|
|
echo "=== Start stopped Proxmox containers (E2E 502 fix) ==="
|
|
echo " dry-run=$DRY_RUN"
|
|
echo ""
|
|
|
|
start_stopped_on_host "$PROXMOX_ML110" "$VMIDS_DBIS" "ML110 (DBIS)"
|
|
echo ""
|
|
start_stopped_on_host "$PROXMOX_R630_01" "$VMIDS_RPC" "r630-01 (RPC 2101)"
|
|
# Also try DBIS on r630-01 in case layout differs
|
|
start_stopped_on_host "$PROXMOX_R630_01" "$VMIDS_DBIS" "r630-01 (DBIS if present)"
|
|
|
|
echo ""
|
|
log_ok "Done. Re-run E2E routing: ./scripts/verify/verify-end-to-end-routing.sh"
|
|
echo ""
|