Files
proxmox/scripts/check-and-start-rpc-2101.sh

38 lines
2.0 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Check and start Besu RPC on container 2101 (Chain 138 Core — 192.168.11.211).
# Run from a host that can SSH to Proxmox (e.g. root@192.168.11.11).
# Usage: ./scripts/check-and-start-rpc-2101.sh
set -euo pipefail
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
PROXMOX_USER="${PROXMOX_USER:-root}"
# RPC 2101 is on R630 (192.168.11.11) per clear-all-transaction-pools.sh
for HOST in "${PROXMOX_R630:-192.168.11.11}" "${PROXMOX_ML110:-192.168.11.10}"; do
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no "${PROXMOX_USER}@${HOST}" "pct list 2>/dev/null | grep -q '2101'"; then
echo "RPC container 2101 found on $HOST. Checking service..."
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no "${PROXMOX_USER}@${HOST}" \
"pct exec 2101 -- bash -c '
echo \"--- systemctl status ---\"
systemctl status besu-rpc-core 2>/dev/null || systemctl status besu-rpc 2>/dev/null || systemctl status besu-rpc.service 2>/dev/null || echo \"No besu-rpc* unit found\"
echo \"\"
echo \"--- listening on 8545? ---\"
ss -tlnp 2>/dev/null | grep 8545 || netstat -tlnp 2>/dev/null | grep 8545 || echo \"Nothing on 8545\"
echo \"\"
echo \"--- starting besu-rpc-core (or besu-rpc) ---\"
systemctl start besu-rpc-core 2>/dev/null || systemctl start besu-rpc 2>/dev/null || systemctl start besu-rpc.service 2>/dev/null || true
sleep 3
systemctl is-active besu-rpc-core 2>/dev/null || systemctl is-active besu-rpc 2>/dev/null || echo inactive
ss -tlnp 2>/dev/null | grep 8545 || true
'" 2>&1
echo ""
echo "Wait 1030s then test: curl -s -X POST http://192.168.11.211:8545 -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"method\":\"eth_chainId\",\"params\":[],\"id\":1}'"
exit 0
fi
done
echo "RPC container 2101 not found on Proxmox hosts." >&2
exit 1