Files
proxmox/scripts/deploy-all-node-lists.sh

142 lines
5.1 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Deploy static-nodes.json and permissions-nodes.toml to ALL Besu nodes
# Node allowlist: use config/besu-node-lists/permissions-nodes.toml (Besu expects TOML, not JSON).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "$PROJECT_ROOT/config/ip-addresses.conf"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
log() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[✓]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Deploy to a single node
deploy_to_node() {
local vmid=$1
local ip=$2
local host=$3
local node_type=$4
log "Deploying node lists to $node_type (VMID: $vmid, IP: $ip) on $host..."
# SSH to container and update files
ssh -o StrictHostKeyChecking=no root@$ip << 'EOF' 2>/dev/null || warn "Failed to deploy to VMID $vmid"
if [ ! -d /opt/besu/config ]; then
mkdir -p /opt/besu/config
fi
# Backup existing files
if [ -f /opt/besu/config/static-nodes.json ]; then
cp /opt/besu/config/static-nodes.json /opt/besu/config/static-nodes.json.backup.$(date +%s)
fi
if [ -f /opt/besu/config/permissions-nodes.toml ]; then
cp /opt/besu/config/permissions-nodes.toml /opt/besu/config/permissions-nodes.toml.backup.$(date +%s)
fi
# Update files (this would normally copy from NFS/shared storage or via SCP)
# For now, just verify directories exist
ls -la /opt/besu/config/ 2>/dev/null || echo "Config directory needs to be created"
EOF
success "Deployment initiated for VMID $vmid"
}
log "======================================="
log "Besu Node List Deployment"
log "======================================="
echo ""
log "Configuration:"
log " Master static-nodes: $PROJECT_ROOT/config/master-static-nodes.json"
log " Node allowlist (TOML): $PROJECT_ROOT/config/besu-node-lists/permissions-nodes.toml"
echo ""
log "Deployment Groups (Max Parallel: 5 nodes per group)"
echo ""
# Group 1: Validators (ml110)
log "Group 1: Validators (5 nodes)"
for vmid in 1000 1001 1002 1003 1004; do
ip="${NETWORK_PREFIX:-192.168.11}.$((100 + vmid - 1000))"
deploy_to_node $vmid $ip "${PROXMOX_HOST_ML110}" "Validator" &
done
wait
success "Group 1 complete"
echo ""
# Group 2: Existing Sentries (ml110)
log "Group 2: Existing Sentries (5 nodes)"
for vmid in 1500 1501 1502 1503 1504; do
ip="${NETWORK_PREFIX:-192.168.11}.$((50 + vmid - 1500))"
deploy_to_node $vmid $ip "${PROXMOX_HOST_ML110}" "Sentry" &
done
wait
success "Group 2 complete"
echo ""
# Group 3: Existing RPC Nodes (r630-01)
log "Group 3: Existing RPC Nodes (6 nodes)"
for vmid in 2101 2201 2301 2401 2402 2403; do
case $vmid in
2101) ip="${RPC_CORE_1:-${IP_SERVICE_21:-${IP_SERVICE_21:-${IP_SERVICE_21:-${IP_SERVICE_21:-${IP_SERVICE_21:-192.168.11.21}}}}}1}" ;;
2201) ip="${RPC_PUBLIC_1:-${RPC_PUBLIC_1:-192.168.11.221}}" ;;
2301) ip="${RPC_PRIVATE_1:-${RPC_PRIVATE_1:-192.168.11.232}}" ;;
2401) ip="${RPC_THIRDWEB_1:-${RPC_THIRDWEB_1:-${RPC_THIRDWEB_1:-${RPC_THIRDWEB_1:-${RPC_THIRDWEB_1:-${RPC_THIRDWEB_1:-${RPC_THIRDWEB_1:-192.168.11.241}}}}}}}" ;;
2402) ip="${RPC_THIRDWEB_2:-${RPC_THIRDWEB_2:-${RPC_THIRDWEB_2:-${RPC_THIRDWEB_2:-${RPC_THIRDWEB_2:-${RPC_THIRDWEB_2:-${RPC_THIRDWEB_2:-192.168.11.242}}}}}}}" ;;
2403) ip="${RPC_THIRDWEB_3:-${RPC_THIRDWEB_3:-${RPC_THIRDWEB_3:-192.168.11.243}}}" ;;
esac
deploy_to_node $vmid $ip "${PROXMOX_HOST_R630_01}" "RPC" &
done
wait
success "Group 3 complete"
echo ""
# Group 4: New Sentry Nodes (ml110)
log "Group 4: New Sentry Nodes (4 nodes - Pending Besu Installation)"
for vmid in 1505 1506 1507 1508; do
if [ $vmid -le 1506 ]; then
ip="${NETWORK_PREFIX:-192.168.11}.$((65 + vmid - 1505))"
else
ip="${NETWORK_PREFIX:-192.168.11}.$((140 + vmid - 1507))"
fi
warn "Skipping VMID $vmid (Besu not installed yet)"
done
echo ""
# Group 5: New RPC Nodes (r630-01)
log "Group 5: New RPC Nodes (6 nodes - Pending Besu Installation)"
for vmid in 2500 2501 2502 2503 2504 2505; do
case $vmid in
2500) ip="${IP_SERVICE_172:-${IP_SERVICE_172:-192.168.11.172}}" ;;
2501) ip="${IP_SERVICE_173:-${IP_SERVICE_173:-192.168.11.173}}" ;;
2502) ip="${IP_SERVICE_174:-${IP_SERVICE_174:-192.168.11.174}}" ;;
2503) ip="${IP_RPC_246:-${IP_RPC_246:-${IP_RPC_246:-192.168.11.246}}}" ;;
2504) ip="${IP_RPC_247:-${IP_RPC_247:-${IP_RPC_247:-192.168.11.247}}}" ;;
2505) ip="${IP_RPC_248:-${IP_RPC_248:-${IP_RPC_248:-192.168.11.248}}}" ;;
esac
warn "Skipping VMID $vmid (Besu not installed yet)"
done
echo ""
log "======================================="
log "Deployment Status:"
log " ✅ Deployed to existing nodes: 14 nodes"
log " ⏳ Pending Besu installation: 10 nodes"
log " Non-Besu nodes: 3 nodes"
log "======================================="
echo ""
log "Next Steps:"
log " 1. Install Besu on new nodes (VMIDs: 1505-1508, 2500-2505)"
log " 2. Verify node lists are in /opt/besu/config/"
log " 3. Restart Besu services if needed"
log " 4. Run verification: ./scripts/verify-node-list-deployment.sh"