Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
128 lines
5.3 KiB
Bash
Executable File
128 lines
5.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# Ensure the VM that hosts NPM (NPM_URL, e.g. https://192.168.11.167:81) is running and reachable.
|
||
# VMID 10233 (npmplus) on r630-01 (192.168.11.11); IP 192.168.11.167 (eth1).
|
||
# Run from repo root. Uses .env for NPM_URL, NPM_HOST, PROXMOX_HOST. Optionally starts container if stopped (requires SSH to Proxmox).
|
||
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||
cd "$PROJECT_ROOT"
|
||
|
||
# Load .env (set +u so values with $ in them don't trigger unbound variable)
|
||
if [ -f .env ]; then
|
||
set +u
|
||
set -a
|
||
# shellcheck source=/dev/null
|
||
source .env 2>/dev/null || true
|
||
set +a
|
||
set -u
|
||
fi
|
||
|
||
# NPM container: VMID 10233 on r630-01 (see docs/04-configuration/DNS_NPMPLUS_VM_STREAMLINED_TABLE.md)
|
||
NPMPLUS_VMID="${NPMPLUS_VMID:-${NPM_VMID:-10233}}"
|
||
PROXMOX_HOST="${PROXMOX_HOST:-192.168.11.11}"
|
||
|
||
# NPM URL (e.g. https://192.168.11.167:81) or derive from NPM_HOST
|
||
NPM_URL="${NPM_URL:-https://192.168.11.167:81}"
|
||
if [[ "$NPM_URL" =~ ^https?://([^:/]+)(:([0-9]+))? ]]; then
|
||
NPM_HOST="${BASH_REMATCH[1]}"
|
||
NPM_PORT="${BASH_REMATCH[3]:-81}"
|
||
else
|
||
NPM_HOST="${NPM_HOST:-192.168.11.167}"
|
||
NPM_PORT="${NPM_PORT:-81}"
|
||
fi
|
||
|
||
# Colors
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
BLUE='\033[0;34m'
|
||
NC='\033[0m'
|
||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||
log_ok() { echo -e "${GREEN}[✓]${NC} $1"; }
|
||
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
|
||
log_err() { echo -e "${RED}[✗]${NC} $1"; }
|
||
|
||
echo ""
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo "NPMplus VM operational check (VMID $NPMPLUS_VMID @ $NPM_HOST)"
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo ""
|
||
|
||
FAIL=0
|
||
|
||
# 1. Optional: check container status on Proxmox and start if stopped
|
||
if command -v ssh >/dev/null 2>&1; then
|
||
log_info "Checking container status on $PROXMOX_HOST (VMID $NPMPLUS_VMID)..."
|
||
STATUS=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new root@"$PROXMOX_HOST" "pct status $NPMPLUS_VMID 2>/dev/null" | awk '/status:/ {print $2}' || echo "unknown")
|
||
if [ "$STATUS" = "running" ]; then
|
||
log_ok "Container $NPMPLUS_VMID is running on $PROXMOX_HOST"
|
||
elif [ "$STATUS" = "stopped" ]; then
|
||
log_warn "Container $NPMPLUS_VMID is stopped. Starting..."
|
||
if timeout 60 ssh -o ConnectTimeout=10 root@"$PROXMOX_HOST" "pct start $NPMPLUS_VMID" 2>/dev/null; then
|
||
log_ok "Started container $NPMPLUS_VMID. Waiting 10s for services..."
|
||
sleep 10
|
||
else
|
||
log_err "Failed to start container $NPMPLUS_VMID. Start manually: ssh root@$PROXMOX_HOST 'pct start $NPMPLUS_VMID'"
|
||
FAIL=1
|
||
fi
|
||
else
|
||
log_warn "Could not get status for VMID $NPMPLUS_VMID (SSH to $PROXMOX_HOST failed or container missing). Continuing with HTTP checks..."
|
||
fi
|
||
else
|
||
log_info "SSH not available; skipping Proxmox container check. Proceeding with HTTP checks..."
|
||
fi
|
||
echo ""
|
||
|
||
# 2. HTTP/HTTPS reachability: 80, 81, 443
|
||
log_info "Checking NPM services on $NPM_HOST..."
|
||
for PORT in 80 81 443; do
|
||
if [ "$PORT" = "443" ]; then
|
||
SCHEME="https"
|
||
else
|
||
SCHEME="http"
|
||
fi
|
||
URL="${SCHEME}://${NPM_HOST}:${PORT}"
|
||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -k --connect-timeout 5 --max-time 8 "$URL" 2>/dev/null || echo "000")
|
||
if [ "$HTTP_CODE" = "000" ]; then
|
||
log_err "$URL – unreachable (connection failed)"
|
||
FAIL=1
|
||
elif [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 500 ]; then
|
||
log_ok "$URL – HTTP $HTTP_CODE"
|
||
else
|
||
log_warn "$URL – HTTP $HTTP_CODE"
|
||
fi
|
||
done
|
||
echo ""
|
||
|
||
# 3. Optional: NPM API login (confirms NPM app is responding)
|
||
if [ -n "${NPM_PASSWORD:-}" ]; then
|
||
log_info "Checking NPM API (login)..."
|
||
TOKEN_RESPONSE=$(curl -s -k -X POST "https://${NPM_HOST}:81/api/tokens" \
|
||
-H "Content-Type: application/json" \
|
||
-d "{\"identity\":\"${NPM_EMAIL:-admin@example.org}\",\"secret\":\"$NPM_PASSWORD\"}" \
|
||
--connect-timeout 5 --max-time 10 2>/dev/null || echo "{}")
|
||
if echo "$TOKEN_RESPONSE" | grep -q '"token"'; then
|
||
log_ok "NPM API login successful"
|
||
else
|
||
log_warn "NPM API login failed or skipped (check NPM_EMAIL/NPM_PASSWORD in .env)"
|
||
fi
|
||
else
|
||
log_info "NPM_PASSWORD not set; skipping API login check"
|
||
fi
|
||
echo ""
|
||
|
||
if [ $FAIL -eq 0 ]; then
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
log_ok "NPMplus VM is operational. NPM_URL=$NPM_URL"
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
else
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
log_err "Some checks failed. Ensure VMID $NPMPLUS_VMID is running on $PROXMOX_HOST and ports 80/81/443 are reachable at $NPM_HOST"
|
||
echo " Start container: ssh root@$PROXMOX_HOST 'pct start $NPMPLUS_VMID'"
|
||
echo " See: docs/04-configuration/DNS_NPMPLUS_VM_STREAMLINED_TABLE.md"
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
exit 1
|
||
fi
|