Files
proxmox/scripts/besu/deploy-genesis-and-node-lists-to-rpcs.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

56 lines
3.4 KiB
Bash

#!/usr/bin/env bash
# Deploy canonical genesis.json, static-nodes.json, permissions-nodes.toml to specified VMIDs
# and restart Besu. Usage: VMIDS="2401 2402 2403 2500 2501 2502 2503 2504 2505" bash scripts/besu/deploy-genesis-and-node-lists-to-rpcs.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
VMIDS="${VMIDS:-2401 2402 2403 2500 2501 2502 2503 2504 2505}"
GENESIS="${PROJECT_ROOT}/smom-dbis-138-proxmox/config/genesis.json"
STATIC="${PROJECT_ROOT}/config/besu-node-lists/static-nodes.json"
PERMS="${PROJECT_ROOT}/config/besu-node-lists/permissions-nodes.toml"
declare -A HOST_BY_VMID
for v in 2500 2501 2502 2503 2504 2505; do HOST_BY_VMID[$v]="${PROXMOX_R630_01:-192.168.11.11}"; done
for v in 2401; do HOST_BY_VMID[$v]="${PROXMOX_R630_02:-192.168.11.12}"; done
for v in 2402 2403; do HOST_BY_VMID[$v]="${PROXMOX_ML110:-192.168.11.10}"; done
SSH_OPTS="-o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new"
[[ ! -f "$GENESIS" ]] && { echo "ERROR: $GENESIS not found"; exit 1; }
[[ ! -f "$STATIC" ]] && { echo "ERROR: $STATIC not found"; exit 1; }
[[ ! -f "$PERMS" ]] && { echo "ERROR: $PERMS not found"; exit 1; }
echo "Deploying genesis.json + static-nodes.json + permissions-nodes.toml to: $VMIDS"
echo ""
for vmid in $VMIDS; do
host="${HOST_BY_VMID[$vmid]:-}"
[[ -z "$host" ]] && { echo "VMID $vmid: no 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 @ $host: skip (not running)"
continue
fi
echo "--- VMID $vmid @ $host ---"
scp -q $SSH_OPTS "$GENESIS" "$STATIC" "$PERMS" "root@${host}:/tmp/" || { echo " scp failed"; continue; }
ssh $SSH_OPTS "root@$host" "pct exec $vmid -- mkdir -p /etc/besu"
ssh $SSH_OPTS "root@$host" "pct push $vmid /tmp/genesis.json /etc/besu/genesis.json && pct push $vmid /tmp/static-nodes.json /etc/besu/static-nodes.json && pct push $vmid /tmp/permissions-nodes.toml /etc/besu/permissions-nodes.toml"
ssh $SSH_OPTS "root@$host" "pct exec $vmid -- chown besu:besu /etc/besu/genesis.json /etc/besu/static-nodes.json /etc/besu/permissions-nodes.toml 2>/dev/null || pct exec $vmid -- chown root:root /etc/besu/genesis.json /etc/besu/static-nodes.json /etc/besu/permissions-nodes.toml"
# Point config to /etc/besu/ (any .toml in /etc/besu/)
ssh $SSH_OPTS "root@$host" "pct exec $vmid -- sed -i 's|genesis-file=.*|genesis-file=\"/etc/besu/genesis.json\"|; s|static-nodes-file=.*|static-nodes-file=\"/etc/besu/static-nodes.json\"|; s|permissions-nodes-config-file=.*|permissions-nodes-config-file=\"/etc/besu/permissions-nodes.toml\"|' /etc/besu/*.toml 2>/dev/null || true"
# Restart Besu
result=$(ssh $SSH_OPTS "root@$host" "pct exec $vmid -- bash -c 'svc=\$(systemctl list-units --type=service --no-legend 2>/dev/null | grep -iE \"besu-validator|besu-sentry|besu-rpc|besu\\.service\" | head -1 | awk \"{print \\\$1}\"); if [ -n \"\$svc\" ]; then systemctl restart \"\$svc\" && echo \"OK:\$svc\"; else echo \"NONE\"; fi'" 2>/dev/null || echo "FAIL")
if [[ "$result" == OK:* ]]; then
echo " deployed + restarted (${result#OK:})"
else
echo " deployed; restart result: $result"
fi
ssh $SSH_OPTS "root@$host" "rm -f /tmp/genesis.json /tmp/static-nodes.json /tmp/permissions-nodes.toml"
done
echo ""
echo "Done."