Files
proxmox/scripts/maintenance/npmplus-verify-port81.sh
defiQUG bad8fdc98c
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
scripts: portal login, PMM mesh install, ops template audit, NPM verify, route matrix export
Made-with: Cursor
2026-03-27 18:46:42 -07:00

21 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# NPMplus admin API on loopback :81 inside CT 10233 (r630-01).
# Ref: docs/04-configuration/NPMPLUS_QUICK_REF.md
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
# shellcheck source=../config
[[ -f "${PROJECT_ROOT}/config/ip-addresses.conf" ]] && source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
SSH_HOST="${NPMPLUS_SSH_HOST:-${PROXMOX_HOST_R630_01:-192.168.11.11}}"
VMID="${NPMPLUS_VMID:-10233}"
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new"
echo "NPMplus :81 check via ssh root@${SSH_HOST} pct exec ${VMID}"
# First hop only (no -L): NPM often 301/308 to HTTPS; following redirects breaks on localhost TLS.
raw="$(timeout 45 ssh $SSH_OPTS "root@${SSH_HOST}" "pct exec ${VMID} -- sh -c 'curl -s -o /dev/null -w \"%{http_code}\" --connect-timeout 5 http://127.0.0.1:81/ 2>/dev/null'" 2>/dev/null || true)"
code="$(echo "$raw" | tr -d '\r\n' | grep -oE '[0-9]{3}' | tail -1)"
[[ -n "$code" ]] || code="000"
echo "HTTP ${code}"
[[ "$code" =~ ^(2[0-9]{2}|3[0-9]{2}|401|403)$ ]] || { echo "Unexpected code (want 2xx/3xx/401/403 = reachable)"; exit 1; }
echo "OK"