Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
81 lines
3.7 KiB
Bash
Executable File
81 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Fix all Besu nodes: deploy canonical node lists, normalize config (TOML permissions path,
|
|
# remove tx-pool-min-score, ensure genesis), then restart Besu.
|
|
# Run from project root. Usage: bash scripts/besu/fix-all-besu-nodes.sh [--dry-run] [--no-restart]
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
|
|
|
DRY_RUN=false
|
|
NO_RESTART=false
|
|
for arg in "${@:-}"; do
|
|
[[ "$arg" == "--dry-run" ]] && DRY_RUN=true
|
|
[[ "$arg" == "--no-restart" ]] && NO_RESTART=true
|
|
done
|
|
|
|
# Same host/VMID as deploy-besu-node-lists-to-all.sh
|
|
declare -A HOST_BY_VMID
|
|
for v in 1000 1001 1002 1500 1501 1502 2101 2500 2501 2502 2503 2504 2505; do HOST_BY_VMID[$v]="${PROXMOX_R630_01:-${PROXMOX_HOST_R630_01:-192.168.11.11}}"; done
|
|
for v in 2201 2303 2401; do HOST_BY_VMID[$v]="${PROXMOX_R630_02:-${PROXMOX_HOST_R630_02:-192.168.11.12}}"; done
|
|
for v in 1003 1004 1503 1504 1505 1506 1507 1508 2102 2301 2304 2305 2306 2307 2308 2400 2402 2403; do HOST_BY_VMID[$v]="${PROXMOX_ML110:-${PROXMOX_HOST_ML110:-192.168.11.10}}"; done
|
|
|
|
BESU_VMIDS=(1000 1001 1002 1003 1004 1500 1501 1502 1503 1504 1505 1506 1507 1508 2101 2102 2201 2301 2303 2304 2305 2306 2307 2308 2400 2401 2402 2403 2500 2501 2502 2503 2504 2505)
|
|
STATIC="${PROJECT_ROOT}/config/besu-node-lists/static-nodes.json"
|
|
PERMS="${PROJECT_ROOT}/config/besu-node-lists/permissions-nodes.toml"
|
|
SSH_OPTS="-o ConnectTimeout=8 -o StrictHostKeyChecking=accept-new"
|
|
|
|
if [[ ! -f "$STATIC" ]] || [[ ! -f "$PERMS" ]]; then
|
|
echo "ERROR: Missing $STATIC or $PERMS" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== Fix all Besu nodes ==="
|
|
echo " 1. Deploy node lists to all nodes"
|
|
echo " 2. Fix config on each node (permissions TOML path, remove tx-pool-min-score, genesis)"
|
|
echo " 3. Restart Besu on all nodes"
|
|
if $DRY_RUN; then echo " [DRY-RUN]"; fi
|
|
if $NO_RESTART; then echo " [NO-RESTART]"; fi
|
|
echo ""
|
|
|
|
# Step 1: Deploy node lists
|
|
echo "--- Step 1: Deploy static-nodes.json and permissions-nodes.toml ---"
|
|
if ! $DRY_RUN; then
|
|
bash "${PROJECT_ROOT}/scripts/deploy-besu-node-lists-to-all.sh" 2>/dev/null || true
|
|
fi
|
|
echo ""
|
|
|
|
# Step 2: Fix config on each running node (permissions path, remove tx-pool-min-score, genesis)
|
|
echo "--- Step 2: Fix config on each node ---"
|
|
for vmid in "${BESU_VMIDS[@]}"; do
|
|
host="${HOST_BY_VMID[$vmid]:-}"
|
|
[[ -z "$host" ]] && continue
|
|
running=$(ssh $SSH_OPTS "root@$host" "pct status $vmid 2>/dev/null | awk '{print \$2}'" 2>/dev/null || echo "")
|
|
if [[ "$running" != "running" ]]; then
|
|
echo " VMID $vmid: skip (not running)"
|
|
continue
|
|
fi
|
|
if $DRY_RUN; then
|
|
echo " VMID $vmid: [dry-run] would fix config"
|
|
continue
|
|
fi
|
|
ssh $SSH_OPTS "root@$host" "pct exec $vmid -- bash -c 'for f in /etc/besu/*.toml /config/*.toml; do [ -f \"\$f\" ] || continue; sed -i \"s|permissions-nodes-config-file=.*|permissions-nodes-config-file=\\\"/etc/besu/permissions-nodes.toml\\\"|\" \"\$f\"; sed -i \"/^tx-pool-min-score=/d\" \"\$f\"; sed -i \"s|static-nodes-file=.*|static-nodes-file=\\\"/etc/besu/static-nodes.json\\\"|\" \"\$f\"; done; [ -f /etc/besu/genesis.json ] && [ ! -f /genesis/genesis.json ] && cp /etc/besu/genesis.json /genesis/genesis.json 2>/dev/null; true'" 2>/dev/null && echo " VMID $vmid: config fixed" || echo " VMID $vmid: config fix skipped/failed"
|
|
done
|
|
echo ""
|
|
|
|
# Step 3: Restart Besu
|
|
if $NO_RESTART; then
|
|
echo "--- Step 3: skipped (--no-restart) ---"
|
|
echo "Run: bash scripts/besu/restart-besu-reload-node-lists.sh"
|
|
exit 0
|
|
fi
|
|
echo "--- Step 3: Restart Besu on all nodes ---"
|
|
if ! $DRY_RUN; then
|
|
bash "${PROJECT_ROOT}/scripts/besu/restart-besu-reload-node-lists.sh" 2>/dev/null || true
|
|
fi
|
|
echo ""
|
|
echo "Done."
|