Files
proxmox/scripts/archive/consolidated/fix/fix-blockscout-network-access.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

138 lines
5.3 KiB
Bash
Executable File

#!/usr/bin/env bash
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
# Fix Blockscout to be accessible on network port 4000
# This enables the direct route configuration
# Usage: ./fix-blockscout-network-access.sh [proxmox-host]
VMID=5000
BLOCKSCOUT_PORT=4000
PROXMOX_HOST="${1:-pve2}"
echo "=========================================="
echo "Fix Blockscout Network Access"
echo "=========================================="
echo "VMID: $VMID"
echo "Port: $BLOCKSCOUT_PORT"
echo "=========================================="
echo ""
# Check if we're on Proxmox host
if ! command -v pct &>/dev/null; then
echo "⚠️ pct command not available"
echo " This script should be run on Proxmox host"
echo " Using SSH to $PROXMOX_HOST..."
EXEC_PREFIX="ssh root@$PROXMOX_HOST"
else
EXEC_PREFIX=""
fi
# Step 1: Check Blockscout service status
echo "=== Step 1: Checking Blockscout Service ==="
if [ -n "$EXEC_PREFIX" ]; then
SERVICE_STATUS=$($EXEC_PREFIX "pct exec $VMID -- systemctl is-active blockscout.service 2>/dev/null" || echo "inactive")
else
SERVICE_STATUS=$(pct exec $VMID -- systemctl is-active blockscout.service 2>/dev/null || echo "inactive")
fi
if [ "$SERVICE_STATUS" != "active" ]; then
echo "❌ Blockscout service is not running (status: $SERVICE_STATUS)"
echo ""
echo "Starting Blockscout service..."
if [ -n "$EXEC_PREFIX" ]; then
$EXEC_PREFIX "pct exec $VMID -- systemctl start blockscout.service"
else
pct exec $VMID -- systemctl start blockscout.service
fi
sleep 5
echo "✅ Blockscout service started"
else
echo "✅ Blockscout service is running"
fi
echo ""
# Step 2: Check what port Blockscout is listening on
echo "=== Step 2: Checking Port Configuration ==="
if [ -n "$EXEC_PREFIX" ]; then
PORT_CHECK=$($EXEC_PREFIX "pct exec $VMID -- ss -tlnp 2>/dev/null | grep :$BLOCKSCOUT_PORT || echo 'not found'")
else
PORT_CHECK=$(pct exec $VMID -- ss -tlnp 2>/dev/null | grep :$BLOCKSCOUT_PORT || echo "not found")
fi
if echo "$PORT_CHECK" | grep -q "127.0.0.1:$BLOCKSCOUT_PORT"; then
echo "⚠️ Blockscout is listening on 127.0.0.1:$BLOCKSCOUT_PORT (localhost only)"
echo " Need to configure it to listen on 0.0.0.0:$BLOCKSCOUT_PORT"
NEEDS_CONFIG=true
elif echo "$PORT_CHECK" | grep -q "0.0.0.0:$BLOCKSCOUT_PORT\|:$BLOCKSCOUT_PORT.*0.0.0.0"; then
echo "✅ Blockscout is already listening on 0.0.0.0:$BLOCKSCOUT_PORT (network accessible)"
NEEDS_CONFIG=false
elif echo "$PORT_CHECK" | grep -q ":$BLOCKSCOUT_PORT"; then
echo "✅ Blockscout is listening on port $BLOCKSCOUT_PORT"
NEEDS_CONFIG=false
else
echo "❌ Blockscout is NOT listening on port $BLOCKSCOUT_PORT"
echo " Port check: $PORT_CHECK"
NEEDS_CONFIG=true
fi
echo ""
# Step 3: Check if Blockscout is in Docker
if [ "$NEEDS_CONFIG" = true ]; then
echo "=== Step 3: Checking Blockscout Configuration ==="
if [ -n "$EXEC_PREFIX" ]; then
BLOCKSCOUT_CONTAINER=$($EXEC_PREFIX "pct exec $VMID -- docker ps --format '{{.Names}}' | grep blockscout | grep -v postgres | head -1" || echo "")
else
BLOCKSCOUT_CONTAINER=$(pct exec $VMID -- docker ps --format '{{.Names}}' | grep blockscout | grep -v postgres | head -1 || echo "")
fi
if [ -n "$BLOCKSCOUT_CONTAINER" ]; then
echo "✅ Found Blockscout container: $BLOCKSCOUT_CONTAINER"
echo ""
echo "For Docker containers, check docker-compose.yml or environment variables:"
echo " - PORT environment variable should be set"
echo " - Port binding should be: '4000:4000' (not '127.0.0.1:4000:4000')"
echo " - Check: pct exec $VMID -- docker inspect $BLOCKSCOUT_CONTAINER | grep -i port"
echo ""
else
echo "⚠️ Blockscout container not found"
echo " Check if Blockscout is running as a systemd service"
echo " Check: pct exec $VMID -- systemctl cat blockscout.service"
echo ""
fi
fi
# Step 4: Test network accessibility
echo "=== Step 4: Testing Network Accessibility ==="
if [ -n "$EXEC_PREFIX" ]; then
NETWORK_TEST=$($EXEC_PREFIX "curl -s -o /dev/null -w '%{http_code}' --connect-timeout 5 http://${IP_BLOCKSCOUT}:$BLOCKSCOUT_PORT/api/v2/stats 2>/dev/null" || echo "000")
else
NETWORK_TEST=$(curl -s -o /dev/null -w '%{http_code}' --connect-timeout 5 http://${IP_BLOCKSCOUT}:$BLOCKSCOUT_PORT/api/v2/stats 2>/dev/null || echo "000")
fi
if [ "$NETWORK_TEST" = "200" ]; then
echo "✅ Blockscout is network accessible (HTTP $NETWORK_TEST)"
echo "✅ Direct route is ready to configure"
echo ""
echo "Next step: Update NPMplus configuration"
echo " - Log into NPMplus: https://192.168.0.166:81"
echo " - Find 'explorer.d-bis.org' proxy host"
echo " - Update Forward Port: 80 → 4000"
echo " - Save changes"
exit 0
else
echo "❌ Blockscout is NOT network accessible (HTTP $NETWORK_TEST)"
echo ""
echo "Configuration needed:"
echo " 1. Configure Blockscout to listen on 0.0.0.0:$BLOCKSCOUT_PORT"
echo " 2. For Docker: Update docker-compose.yml port binding"
echo " 3. For systemd: Update service environment variables"
echo " 4. Restart Blockscout service"
echo ""
exit 1
fi