#!/usr/bin/env bash # Apply peer-connections plan: deploy cleaned node lists, restart RPC 2101, optionally 2102/2201. # See: docs/08-monitoring/PEER_CONNECTIONS_PLAN.md # # Usage: ./scripts/maintenance/apply-peer-plan-fixes.sh [--deploy-only] [--restart-2101-only] # --deploy-only Only deploy node lists (no restarts). # --restart-2101-only Only restart VMID 2101 (assumes lists already deployed). # Requires: SSH to Proxmox hosts (r630-01, r630-02, ml110). Run from LAN. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" [[ -f "${PROJECT_ROOT}/config/ip-addresses.conf" ]] && source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true DEPLOY_ONLY=false RESTART_2101_ONLY=false for a in "$@"; do [[ "$a" == "--deploy-only" ]] && DEPLOY_ONLY=true [[ "$a" == "--restart-2101-only" ]] && RESTART_2101_ONLY=true done echo "" echo "=== Apply peer plan fixes ===" echo " deploy-only=$DEPLOY_ONLY restart-2101-only=$RESTART_2101_ONLY" echo "" if [[ "$RESTART_2101_ONLY" != true ]]; then echo "--- Deploy node lists to all Besu nodes ---" "$PROJECT_ROOT/scripts/deploy-besu-node-lists-to-all.sh" || { echo "Deploy failed (SSH?)."; exit 1; } echo "" fi if [[ "$DEPLOY_ONLY" == true ]]; then echo "Done (deploy only). To restart RPC 2101: $PROJECT_ROOT/scripts/maintenance/fix-core-rpc-2101.sh --restart-only" exit 0 fi echo "--- Restart RPC 2101 to load new node lists ---" "$PROJECT_ROOT/scripts/maintenance/fix-core-rpc-2101.sh" --restart-only || { echo "Restart 2101 failed."; exit 1; } echo "" echo "--- Optional: 2102 and 2201 max-peers=32 ---" echo "Repo updated: smom-dbis-138/config/config-rpc-public.toml has max-peers=32." echo "To apply on nodes (from host with SSH):" echo " - 2102 (ml110): ensure config uses max-peers=32 (e.g. copy from repo config-rpc-core.toml), restart Besu." echo " - 2201 (r630-02): ensure config uses max-peers=32 (e.g. copy from repo config-rpc-public.toml), restart Besu." echo "Then re-run: ./scripts/verify/check-rpc-2101-all-peers.sh" echo "" echo "Done. Verify: ./scripts/verify/verify-rpc-2101-approve-and-sync.sh && ./scripts/verify/check-rpc-2101-all-peers.sh" echo ""