Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- Config, docs, scripts, and backup manifests - Submodule refs unchanged (m = modified content in submodules) Made-with: Cursor
43 lines
1.2 KiB
Bash
Executable File
43 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Check NPMplus health for Keepalived. Return 0 if healthy, 1 if unhealthy.
|
|
# Deploy to /usr/local/bin/check-npmplus-health.sh on both Proxmox hosts.
|
|
|
|
set -euo pipefail
|
|
|
|
PRIMARY_VMID="${PRIMARY_VMID:-10233}"
|
|
SECONDARY_VMID="${SECONDARY_VMID:-10234}"
|
|
|
|
# Determine VMID by hostname (when run on Proxmox host)
|
|
HOSTNAME=$(hostname 2>/dev/null || echo "")
|
|
if [[ "$HOSTNAME" == "r630-01" ]]; then
|
|
VMID="$PRIMARY_VMID"
|
|
elif [[ "$HOSTNAME" == "r630-02" ]]; then
|
|
VMID="$SECONDARY_VMID"
|
|
else
|
|
# Fallback: try primary then secondary
|
|
if pct status "$PRIMARY_VMID" 2>/dev/null | grep -q "running"; then
|
|
VMID="$PRIMARY_VMID"
|
|
elif pct status "$SECONDARY_VMID" 2>/dev/null | grep -q "running"; then
|
|
VMID="$SECONDARY_VMID"
|
|
else
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Check if container is running
|
|
if ! pct status "$VMID" 2>/dev/null | grep -q "running"; then
|
|
exit 1
|
|
fi
|
|
|
|
# Check if NPMplus container is healthy (Docker service inside CT)
|
|
if ! pct exec "$VMID" -- docker ps --filter "name=npmplus" --format "{{.Status}}" 2>/dev/null | grep -qE "healthy|Up"; then
|
|
exit 1
|
|
fi
|
|
|
|
# Check if NPMplus admin/API responds
|
|
if ! pct exec "$VMID" -- curl -s -k -f -o /dev/null --max-time 5 https://localhost:81 2>/dev/null; then
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|