Files
proxmox/scripts/lib/require-proxmox-ssh-for-pct.sh
defiQUG 4ebf2d7902
Some checks failed
Deploy to Phoenix / validate (push) Failing after 1s
Deploy to Phoenix / deploy (push) Has been skipped
Deploy to Phoenix / deploy-atomic-swap-dapp (push) Has been skipped
Deploy to Phoenix / cloudflare (push) Has been skipped
chore(repo): sync operator workspace (config, scripts, docs, multi-chain)
Add optional Cosmos/Engine-X/act-runner templates, CWUSDC/EI-matrix tooling,
non-EVM route planner in multi-chain-execution (tests passing), token list and
extraction updates, and documentation (MetaMask matrix, GRU/CWUSDC packets).

Ignore institutional evidence tarballs/sha256 under reports/status.

Validated with: bash scripts/verify/run-all-validation.sh --skip-genesis

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 16:25:08 -07:00

60 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# Resolve PROXMOX_HOST for pct-over-SSH so operator workstations do not run pct by mistake.
#
# Usage (after VMID is set):
# PROXMOX_MONOREPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" # proxmox repo root
# source "${PROXMOX_MONOREPO_ROOT}/scripts/lib/require-proxmox-ssh-for-pct.sh"
# require_proxmox_ssh_for_pct
#
# Env:
# PROXMOX_HOST If set, use this host (ssh root@$PROXMOX_HOST … pct …).
# VMID Used with get_host_for_vmid when PROXMOX_HOST is unset.
# PROXMOX_MONOREPO_ROOT Proxmox monorepo root (directory containing scripts/lib/load-project-env.sh).
# PROJECT_ROOT Alternative to PROXMOX_MONOREPO_ROOT when sourcing load-project-env.
# DEPLOY_PCT_ON_LOCAL_PVE Set to 1 only on a real Proxmox node (/etc/pve/.members) to run local pct
# without SSH (hypervisor shell only).
require_proxmox_ssh_for_pct() {
local vmid="${VMID:-}"
if [[ "${DEPLOY_PCT_ON_LOCAL_PVE:-0}" == "1" ]]; then
if [[ -r /etc/pve/.members ]]; then
export PROXMOX_HOST=""
echo "NOTE: DEPLOY_PCT_ON_LOCAL_PVE=1 — using pct on this Proxmox node (no SSH)." >&2
return 0
fi
echo "ERROR: DEPLOY_PCT_ON_LOCAL_PVE=1 but this host is not a Proxmox cluster member (/etc/pve/.members missing)." >&2
return 1
fi
if [[ -n "${PROXMOX_HOST:-}" ]]; then
echo "Using Proxmox target: ssh root@${PROXMOX_HOST} (VMID ${vmid:-n/a})" >&2
return 0
fi
if [[ -z "$vmid" ]]; then
echo "ERROR: PROXMOX_HOST is unset and VMID is empty — cannot choose a Proxmox host." >&2
echo " Set PROXMOX_HOST (e.g. 192.168.11.12) or VMID, or run on a PVE node with DEPLOY_PCT_ON_LOCAL_PVE=1." >&2
return 1
fi
local root="${PROXMOX_MONOREPO_ROOT:-${PROJECT_ROOT:-}}"
if [[ -z "$root" || ! -f "$root/scripts/lib/load-project-env.sh" ]]; then
echo "ERROR: Proxmox monorepo root not found (expected scripts/lib/load-project-env.sh under PROXMOX_MONOREPO_ROOT or PROJECT_ROOT)." >&2
return 1
fi
# shellcheck disable=SC1090
PROJECT_ROOT="$root" source "$root/scripts/lib/load-project-env.sh"
local chosen
chosen="$(get_host_for_vmid "$vmid")"
if [[ -z "$chosen" ]]; then
echo "ERROR: get_host_for_vmid returned empty for VMID=$vmid" >&2
return 1
fi
export PROXMOX_HOST="$chosen"
echo "Auto-selected Proxmox host from VMID ${vmid}: ssh root@${PROXMOX_HOST}" >&2
return 0
}