Files
proxmox/scripts/verify/verify-npmplus-running-and-network.sh
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains
- Omit embedded publish git dirs and empty placeholders from index

Made-with: Cursor
2026-04-12 06:12:20 -07:00

131 lines
5.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Verify NPMplus (VMID 10233) is running, has correct IP(s), and uses correct gateway.
# Expected (from config/ip-addresses.conf and docs): VMID 10233 on r630-01;
# IPs 192.168.11.166 (eth0) and/or 192.168.11.167; gateway 192.168.11.1.
#
# Usage:
# On Proxmox host: bash scripts/verify/verify-npmplus-running-and-network.sh
# From repo (via SSH): ssh root@192.168.11.11 'bash -s' < scripts/verify/verify-npmplus-running-and-network.sh
# Or use run-via-proxmox-ssh to copy and run.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
[ -f "${PROJECT_ROOT}/config/ip-addresses.conf" ] && source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
VMID="${NPMPLUS_VMID:-10233}"
EXPECTED_GW="${NETWORK_GATEWAY:-192.168.11.1}"
EXPECTED_IPS=("192.168.11.166" "192.168.11.167") # at least one; .167 is used in UDM Pro
PROXMOX_HOST="${NPMPLUS_HOST:-${PROXMOX_HOST_R630_01:-192.168.11.11}}"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
ok() { echo -e "${GREEN}[✓]${NC} $1"; }
fail() { echo -e "${RED}[✗]${NC} $1"; }
warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "NPMplus (VMID $VMID) running, IP, gateway check"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# 1) Must be run where pct exists (Proxmox host)
if ! command -v pct &>/dev/null; then
fail "pct not found. Run this script on the Proxmox host (e.g. ssh root@${PROXMOX_HOST}) or use: ssh root@${PROXMOX_HOST} 'bash -s' < scripts/verify/verify-npmplus-running-and-network.sh"
exit 1
fi
# 2) Container exists and status
if ! pct status "$VMID" &>/dev/null; then
fail "VMID $VMID not found on this host."
exit 1
fi
STATUS=$(pct status "$VMID" 2>/dev/null | awk '{print $2}')
if [[ "$STATUS" != "running" ]]; then
fail "NPMplus (VMID $VMID) is not running. Status: $STATUS"
info "Start with: pct start $VMID"
info "Configured network (from pct config) verify IP/gw match expected:"
pct config "$VMID" 2>/dev/null | grep -E '^net|^name' || true
echo "Expected: gateway $EXPECTED_GW; IP(s) ${EXPECTED_IPS[*]}"
exit 1
fi
ok "NPMplus (VMID $VMID) is running"
# 3) Network config from container config (host view)
info "Container network config (pct config):"
pct config "$VMID" 2>/dev/null | grep -E '^net|^name' || true
echo ""
# 4) IP and gateway inside container
info "IP addresses and gateway inside container:"
IP_OUT=$(pct exec "$VMID" -- ip -4 addr show 2>/dev/null || true)
GW_OUT=$(pct exec "$VMID" -- ip route show default 2>/dev/null || true)
echo "$IP_OUT"
echo "Default route: $GW_OUT"
echo ""
# Parse default gateway(s)
DEFAULT_ROUTE_COUNT=$(printf '%s\n' "$GW_OUT" | awk '/^default via / {count++} END {print count+0}')
ACTUAL_GW=$(printf '%s\n' "$GW_OUT" | awk '/^default via / {print $3; exit}')
if [[ -n "$ACTUAL_GW" ]]; then
if [[ "$ACTUAL_GW" == "$EXPECTED_GW" ]]; then
ok "Gateway is correct: $ACTUAL_GW"
else
warn "Gateway is $ACTUAL_GW (expected $EXPECTED_GW)"
fi
else
warn "Could not determine default gateway"
fi
if (( DEFAULT_ROUTE_COUNT > 1 )); then
warn "Multiple default routes detected inside container ($DEFAULT_ROUTE_COUNT). NPMplus should normally have a single default route."
fi
# Parse IPs (simple: lines with inet 192.168.11.x)
FOUND_IPS=()
while read -r line; do
if [[ "$line" =~ inet\ (192\.168\.11\.[0-9]+)/ ]]; then
FOUND_IPS+=("${BASH_REMATCH[1]}")
fi
done <<< "$IP_OUT"
if [[ ${#FOUND_IPS[@]} -eq 0 ]]; then
fail "No 192.168.11.x address found in container"
else
ok "Container has IP(s): ${FOUND_IPS[*]}"
MISSING=()
for exp in "${EXPECTED_IPS[@]}"; do
found=false
for g in "${FOUND_IPS[@]}"; do [[ "$g" == "$exp" ]] && found=true; done
[[ "$found" != true ]] && MISSING+=("$exp")
done
if [[ ${#MISSING[@]} -gt 0 ]]; then
warn "Expected at least one of ${EXPECTED_IPS[*]}; missing in container: ${MISSING[*]} (UDM Pro forwards to .167)"
fi
fi
# 5) Admin UI reachable (port 81)
info "Checking NPMplus admin UI (port 81) on container IPs..."
for ip in "${FOUND_IPS[@]}"; do
if pct exec "$VMID" -- curl -s -o /dev/null -w "%{http_code}" --connect-timeout 2 "http://127.0.0.1:81" 2>/dev/null | grep -q '200\|301\|302\|401'; then
ok "Port 81 (admin UI) responding on container"
break
fi
done
if ! pct exec "$VMID" -- curl -s -o /dev/null -w "%{http_code}" --connect-timeout 2 "http://127.0.0.1:81" 2>/dev/null | grep -qE '200|301|302|401'; then
warn "Port 81 did not respond with 2xx/3xx/401 (admin UI may still be starting)"
fi
echo ""
echo "Expected: gateway $EXPECTED_GW; at least one of ${EXPECTED_IPS[*]} (UDM Pro uses .167)."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""