Files
proxmox/scripts/archive/consolidated/deploy/deploy-via-proxmox.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

205 lines
7.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Deploy Bridges via Proxmox Host
# SCPs script to Proxmox host, checks prerequisites, and executes in VM
set -euo pipefail
# Load IP configuration
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
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"
# Configuration
PROXMOX_HOST="${PROXMOX_HOST:-192.168.11.10}"
PROXMOX_USER="${PROXMOX_USER:-root}"
VMID="${VMID:-2101}" # Core RPC node
VM_IP="${RPC_CORE_1}"
DEPLOY_SCRIPT="scripts/deploy-all-bridges-standalone.sh"
REMOTE_SCRIPT_PATH="/tmp/deploy-all-bridges-standalone.sh"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
log_error() { echo -e "${RED}[✗]${NC} $1"; }
log_section() { echo -e "\n${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"; echo -e "${CYAN}$1${NC}"; echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n"; }
log_section "Deploy Bridges via Proxmox Host"
log_info "Proxmox Host: $PROXMOX_HOST"
log_info "VMID: $VMID (besu-rpc-core-1)"
log_info "VM IP: $VM_IP"
# Step 1: Check if script exists locally
if [ ! -f "$DEPLOY_SCRIPT" ]; then
log_error "Deployment script not found: $DEPLOY_SCRIPT"
exit 1
fi
log_success "Deployment script found: $DEPLOY_SCRIPT"
# Step 2: SCP script to Proxmox host
log_section "Step 1: Copy Script to Proxmox Host"
log_info "Copying $DEPLOY_SCRIPT to $PROXMOX_HOST:$REMOTE_SCRIPT_PATH..."
if scp "$DEPLOY_SCRIPT" "${PROXMOX_USER}@${PROXMOX_HOST}:${REMOTE_SCRIPT_PATH}" 2>&1; then
log_success "Script copied to Proxmox host"
else
log_error "Failed to copy script to Proxmox host"
log_info "Manual copy command:"
log_info " scp $DEPLOY_SCRIPT ${PROXMOX_USER}@${PROXMOX_HOST}:${REMOTE_SCRIPT_PATH}"
exit 1
fi
# Step 3: Make script executable on Proxmox host
log_info "Making script executable on Proxmox host..."
ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "chmod +x $REMOTE_SCRIPT_PATH" 2>&1 || {
log_error "Failed to make script executable"
exit 1
}
log_success "Script is executable"
# Step 4: Check VM status
log_section "Step 2: Check VM Status"
log_info "Checking if VMID $VMID is running..."
VM_STATUS=$(ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct status $VMID 2>&1" || echo "")
if echo "$VM_STATUS" | grep -q "running"; then
log_success "VM $VMID is running"
elif echo "$VM_STATUS" | grep -q "stopped"; then
log_error "VM $VMID is stopped. Please start it first:"
log_info " ssh ${PROXMOX_USER}@${PROXMOX_HOST} 'pct start $VMID'"
exit 1
else
log_error "Cannot determine VM status: $VM_STATUS"
exit 1
fi
# Step 5: Check prerequisites in VM
log_section "Step 3: Check Prerequisites in VM"
log_info "Checking prerequisites in VMID $VMID..."
# Check if Foundry is installed
FOUNDRY_CHECK=$(ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- forge --version 2>&1" || echo "")
if echo "$FOUNDRY_CHECK" | grep -q "forge"; then
FORGE_VERSION=$(echo "$FOUNDRY_CHECK" | head -1)
log_success "Foundry installed: $FORGE_VERSION"
else
log_error "Foundry not installed in VM"
log_info "Install Foundry: pct exec $VMID -- bash -c 'curl -L https://foundry.paradigm.xyz | bash && foundryup'"
exit 1
fi
# Check if cast is available
CAST_CHECK=$(ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- cast --version 2>&1" || echo "")
if echo "$CAST_CHECK" | grep -q "cast"; then
log_success "Cast available"
else
log_error "Cast not available"
exit 1
fi
# Check if project directory exists
PROJECT_CHECK=$(ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- test -d /home/intlc/projects/proxmox && echo 'exists' || echo 'missing'" 2>&1)
if echo "$PROJECT_CHECK" | grep -q "exists"; then
log_success "Project directory exists in VM"
else
log_warn "Project directory may not exist in VM"
log_info "You may need to mount or copy the project to the VM"
fi
# Check if .env file exists
ENV_CHECK=$(ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- test -f /home/intlc/projects/proxmox/smom-dbis-138/.env && echo 'exists' || echo 'missing'" 2>&1)
if echo "$ENV_CHECK" | grep -q "exists"; then
log_success ".env file exists in VM"
else
log_warn ".env file may not exist in VM"
log_info "You may need to copy .env file to the VM"
fi
# Step 6: Copy environment file if needed
log_section "Step 4: Prepare Environment"
if [ -f "smom-dbis-138/.env" ]; then
log_info "Copying .env file to VM..."
ENV_CONTENT=$(cat "smom-dbis-138/.env")
ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- bash -c 'mkdir -p /home/intlc/projects/proxmox/smom-dbis-138 && cat > /home/intlc/projects/proxmox/smom-dbis-138/.env <<ENVEOF
$ENV_CONTENT
ENVEOF
'" 2>&1 || {
log_warn "Failed to copy .env file (may already exist)"
}
log_success ".env file prepared in VM"
else
log_warn ".env file not found locally"
fi
# Step 7: Copy necessary scripts
log_section "Step 5: Copy Supporting Scripts"
# Copy gas price calculation script
if [ -f "scripts/calculate-chain138-gas-price.sh" ]; then
log_info "Copying gas price calculation script..."
GAS_SCRIPT=$(cat "scripts/calculate-chain138-gas-price.sh")
ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- bash -c 'mkdir -p /home/intlc/projects/proxmox/scripts && cat > /home/intlc/projects/proxmox/scripts/calculate-chain138-gas-price.sh <<GASEOF
$GAS_SCRIPT
GASEOF
chmod +x /home/intlc/projects/proxmox/scripts/calculate-chain138-gas-price.sh
'" 2>&1 || log_warn "Failed to copy gas script"
log_success "Gas price script copied"
fi
# Step 8: Execute deployment script
log_section "Step 6: Execute Deployment Script"
log_info "Executing deployment script in VMID $VMID..."
log_info "This may take several minutes..."
# Copy script to VM and execute
SCRIPT_CONTENT=$(cat "$DEPLOY_SCRIPT")
ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- bash -c 'cd /home/intlc/projects/proxmox && cat > /tmp/deploy-bridges.sh <<SCRIPTEOF
$SCRIPT_CONTENT
SCRIPTEOF
chmod +x /tmp/deploy-bridges.sh
bash /tmp/deploy-bridges.sh 2>&1 | tee /tmp/deployment-$(date +%Y%m%d-%H%M%S).log
'" 2>&1 | tee /tmp/proxmox-deployment-$(date +%Y%m%d-%H%M%S).log
DEPLOY_EXIT=$?
if [ "$DEPLOY_EXIT" -eq 0 ]; then
log_success "Deployment completed successfully!"
else
log_error "Deployment failed with exit code: $DEPLOY_EXIT"
log_info "Check logs: /tmp/proxmox-deployment-*.log"
exit 1
fi
# Step 9: Retrieve deployment results
log_section "Step 7: Retrieve Deployment Results"
log_info "Retrieving deployed addresses from VM..."
DEPLOYED_ADDRESSES=$(ssh "${PROXMOX_USER}@${PROXMOX_HOST}" "pct exec $VMID -- cat /tmp/chain138-deployed-addresses-*.txt 2>/dev/null | tail -1" 2>&1 || echo "")
if [ -n "$DEPLOYED_ADDRESSES" ]; then
log_success "Deployed addresses retrieved:"
echo "$DEPLOYED_ADDRESSES"
echo "$DEPLOYED_ADDRESSES" > /tmp/chain138-deployed-addresses-proxmox.txt
log_info "Addresses saved to: /tmp/chain138-deployed-addresses-proxmox.txt"
else
log_warn "Could not retrieve deployed addresses"
fi
log_section "Deployment Complete"
log_success "✅ All deployments executed via Proxmox host"