Files
proxmox/scripts/archive/consolidated/fix/fix-npmplus-backend-services.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- 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>
2026-02-12 15:46:57 -08:00

136 lines
5.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fix backend services for NPMplus
set -euo pipefail
# Load IP configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
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_success() { echo -e "${GREEN}[✓]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
log_error() { echo -e "${RED}[✗]${NC} $1"; }
PROXMOX_HOST="${1:-192.168.11.11}"
CONTAINER_ID="${2:-10233}"
AUTO_START="${3:-true}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🔧 NPMplus Backend Services Fix"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Corrected VMID to host mapping based on actual findings
declare -A VMID_HOSTS=(
["5000"]="${PROXMOX_HOST_R630_02}"
["10130"]="${PROXMOX_HOST_R630_01}"
["10150"]="${PROXMOX_HOST_R630_01}"
["10151"]="${PROXMOX_HOST_R630_01}"
["7811"]="${PROXMOX_HOST_R630_02}"
["2101"]="${PROXMOX_HOST_ML110}"
["2201"]="${PROXMOX_HOST_ML110}"
["2301"]="${PROXMOX_HOST_ML110}"
["2302"]="${PROXMOX_HOST_ML110}"
)
started_count=0
failed_count=0
for vmid in "${!VMID_HOSTS[@]}"; do
host="${VMID_HOSTS[$vmid]}"
log_info "Checking VMID $vmid on $host..."
status=$(ssh root@"$host" "pct status $vmid 2>/dev/null || qm status $vmid 2>/dev/null || echo 'not found'")
if echo "$status" | grep -q "stopped"; then
log_warn " VMID $vmid is stopped"
if [ "$AUTO_START" = "true" ]; then
log_info " Starting VMID $vmid..."
start_result=$(ssh root@"$host" "pct start $vmid 2>&1 || qm start $vmid 2>&1" || echo "failed")
if echo "$start_result" | grep -qE "already running|started|OK"; then
log_success " ✓ VMID $vmid started"
started_count=$((started_count + 1))
sleep 2
else
log_error " ✗ Failed: $start_result"
failed_count=$((failed_count + 1))
fi
fi
elif echo "$status" | grep -q "running"; then
log_success " ✓ VMID $vmid is running"
else
log_warn " VMID $vmid: $status"
fi
echo ""
done
# Wait for services to be ready
if [ "$AUTO_START" = "true" ] && [ $started_count -gt 0 ]; then
log_info "Waiting for services to initialize..."
sleep 5
fi
# Verify services
log_info "Verifying backend services..."
echo ""
declare -A BACKEND_SERVICES=(
["${IP_BLOCKSCOUT:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-192.168.11.14}}}0}:80"]="VMID 5000 (blockscout-1)"
["${IP_DBIS_FRONTEND:-${IP_SERVICE_13:-${IP_SERVICE_13:-${IP_SERVICE_13:-192.168.11.13}}}0}:80"]="VMID 10130 (dbis-frontend)"
["${IP_DBIS_API:-192.168.11.155}:3000"]="VMID 10150 (dbis-api-primary)"
["${IP_DBIS_API_2:-192.168.11.156}:3000"]="VMID 10151 (dbis-api-secondary)"
["${IP_SERVICE_36:-${IP_SERVICE_36:-${IP_SERVICE_36:-${IP_SERVICE_36:-192.168.11.36}}}}:80"]="VMID 7811 (mim-api-1)"
["${RPC_CORE_1:-${IP_SERVICE_21:-${IP_SERVICE_21:-${IP_SERVICE_21:-192.168.11.21}}}1}:443"]="VMID 2101 (besu-rpc-core-1)"
["${RPC_PUBLIC_1:-192.168.11.221}:443"]="VMID 2201 (besu-rpc-public-1)"
["${RPC_PRIVATE_1:-192.168.11.232}:443"]="VMID 2301 (besu-rpc-private-1)"
# Note: VMID 2302 (besu-rpc-private-2) - not in latest mapping, may need different IP or is new service
)
working=0
failed=0
for backend in "${!BACKEND_SERVICES[@]}"; do
service_info="${BACKEND_SERVICES[$backend]}"
port="${backend##*:}"
if [ "$port" = "443" ]; then
response=$(ssh root@"$PROXMOX_HOST" "pct exec $CONTAINER_ID -- curl -s -o /dev/null -w '%{http_code}' -I -k --connect-timeout 5 'https://$backend' 2>/dev/null || echo '000'")
else
response=$(ssh root@"$PROXMOX_HOST" "pct exec $CONTAINER_ID -- curl -s -o /dev/null -w '%{http_code}' -I --connect-timeout 5 'http://$backend' 2>/dev/null || echo '000'")
fi
if [ "$response" != "000" ] && [ "$response" != "" ]; then
log_success "$service_info: ✓ (HTTP $response)"
working=$((working + 1))
else
log_warn "$service_info: ✗ Not responding"
failed=$((failed + 1))
fi
done
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
log_info "Summary:"
log_success " Started: $started_count"
log_success " Working: $working/${#BACKEND_SERVICES[@]}"
if [ $failed -gt 0 ]; then
log_warn " Failed: $failed"
fi
if [ $failed_count -gt 0 ]; then
log_warn " Failed to start: $failed_count"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""