Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- 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>
178 lines
6.1 KiB
Bash
Executable File
178 lines
6.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# Push all deployment templates and scripts to Proxmox VE hosts.
|
||
# Required for infra deployment: Besu configs, scripts, lib, config; optionally trigger OS template download on each host.
|
||
#
|
||
# Usage: ./scripts/push-templates-to-proxmox.sh [--download-templates] [--dry-run]
|
||
# --download-templates After pushing files, run pveam download on each host for Debian 12 + Ubuntu 22.04
|
||
# --dry-run Print what would be copied and to which hosts; do not push.
|
||
#
|
||
# Requires: SSH access to Proxmox hosts (config/ip-addresses.conf: ML110, R630_01, R630_02).
|
||
# Run from project root.
|
||
|
||
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
|
||
|
||
export LC_ALL=C
|
||
export LANG=C
|
||
|
||
REMOTE_DIR="/opt/smom-dbis-138-proxmox"
|
||
USER="${PROXMOX_USER:-root}"
|
||
DOWNLOAD_TEMPLATES=false
|
||
DRY_RUN=false
|
||
for a in "$@"; do
|
||
[[ "$a" == "--download-templates" ]] && DOWNLOAD_TEMPLATES=true
|
||
[[ "$a" == "--dry-run" ]] && DRY_RUN=true
|
||
done
|
||
|
||
# All Proxmox hosts (deployment targets)
|
||
HOSTS=(
|
||
"${PROXMOX_HOST_ML110:-192.168.11.10}"
|
||
"${PROXMOX_HOST_R630_01:-192.168.11.11}"
|
||
"${PROXMOX_HOST_R630_02:-192.168.11.12}"
|
||
)
|
||
|
||
# --- Templates and files to push (paths relative to PROJECT_ROOT) ---
|
||
|
||
# 1) LXC OS templates (downloaded on host via pveam, not pushed as files)
|
||
# Required names: debian-12-standard_12.12-1_amd64.tar.zst, ubuntu-22.04-standard_22.04-1_amd64.tar.zst
|
||
# Optional: alpine-3.22-default_* for NPMplus. Use --download-templates to run pveam on each host.
|
||
|
||
# 2) Besu config templates (used by deploy-besu-nodes, copy-configs-to-vm)
|
||
BESU_CONFIGS=(
|
||
smom-dbis-138-proxmox/templates/besu-configs/config-validator.toml
|
||
smom-dbis-138-proxmox/templates/besu-configs/config-sentry.toml
|
||
smom-dbis-138-proxmox/templates/besu-configs/config-rpc-core.toml
|
||
smom-dbis-138-proxmox/templates/besu-configs/config-rpc.toml
|
||
smom-dbis-138-proxmox/templates/besu-configs/config-rpc-4.toml
|
||
)
|
||
BESU_TEMPLATE_DIR="smom-dbis-138-proxmox/templates"
|
||
DOCKER_COMPOSE_TEMPLATE="smom-dbis-138-proxmox/templates/docker-compose-besu-temp.yml"
|
||
|
||
# 3) Config (proxmox.conf, genesis, network – example or real)
|
||
CONFIG_ITEMS=(
|
||
smom-dbis-138-proxmox/config/proxmox.conf
|
||
smom-dbis-138-proxmox/config/proxmox.conf.example
|
||
smom-dbis-138-proxmox/config/genesis.json
|
||
smom-dbis-138-proxmox/config/network.conf
|
||
smom-dbis-138-proxmox/config/network.conf.example
|
||
)
|
||
|
||
# 4) Scripts and lib (entire trees)
|
||
SMOM_SCRIPTS_DIR="smom-dbis-138-proxmox/scripts"
|
||
SMOM_LIB_DIR="smom-dbis-138-proxmox/lib"
|
||
SMOM_INSTALL_DIR="smom-dbis-138-proxmox/install"
|
||
|
||
log_info() { echo "[INFO] $1"; }
|
||
log_ok() { echo "[✓] $1"; }
|
||
log_warn() { echo "[⚠] $1"; }
|
||
log_err() { echo "[✗] $1"; }
|
||
|
||
run_ssh() {
|
||
local host="$1"
|
||
shift
|
||
if [[ "$DRY_RUN" == true ]]; then
|
||
echo " [DRY-RUN] ssh $USER@$host $*"
|
||
return 0
|
||
fi
|
||
ssh -o ConnectTimeout=10 -o BatchMode=yes "$USER@$host" "$@"
|
||
}
|
||
|
||
run_scp() {
|
||
local src="$1"
|
||
local dest="$2"
|
||
if [[ "$DRY_RUN" == true ]]; then
|
||
echo " [DRY-RUN] scp $src -> $dest"
|
||
return 0
|
||
fi
|
||
scp -q "$src" "$dest"
|
||
}
|
||
|
||
push_to_host() {
|
||
local host="$1"
|
||
log_info "Pushing to $USER@$host:$REMOTE_DIR ..."
|
||
|
||
run_ssh "$host" "mkdir -p $REMOTE_DIR/templates/besu-configs $REMOTE_DIR/config $REMOTE_DIR/scripts/deployment $REMOTE_DIR/scripts/validation $REMOTE_DIR/scripts/network $REMOTE_DIR/scripts/manage $REMOTE_DIR/scripts/migration $REMOTE_DIR/scripts/health $REMOTE_DIR/scripts/upgrade $REMOTE_DIR/lib $REMOTE_DIR/install"
|
||
|
||
for f in "${BESU_CONFIGS[@]}"; do
|
||
[[ -f "$f" ]] || continue
|
||
run_scp "$f" "$USER@$host:$REMOTE_DIR/templates/besu-configs/"
|
||
done
|
||
[[ -f "$DOCKER_COMPOSE_TEMPLATE" ]] && run_scp "$DOCKER_COMPOSE_TEMPLATE" "$USER@$host:$REMOTE_DIR/templates/"
|
||
|
||
for f in "${CONFIG_ITEMS[@]}"; do
|
||
[[ -f "$f" ]] || continue
|
||
run_scp "$f" "$USER@$host:$REMOTE_DIR/config/"
|
||
done
|
||
|
||
if [[ -d "$SMOM_SCRIPTS_DIR" ]]; then
|
||
if [[ "$DRY_RUN" == true ]]; then
|
||
echo " [DRY-RUN] scp -r $SMOM_SCRIPTS_DIR -> $host:$REMOTE_DIR/"
|
||
else
|
||
scp -rq "$SMOM_SCRIPTS_DIR" "$USER@$host:$REMOTE_DIR/" 2>/dev/null || true
|
||
fi
|
||
fi
|
||
if [[ -d "$SMOM_LIB_DIR" ]]; then
|
||
for f in "$SMOM_LIB_DIR"/*.sh; do
|
||
[[ -f "$f" ]] || continue
|
||
run_scp "$f" "$USER@$host:$REMOTE_DIR/lib/"
|
||
done
|
||
fi
|
||
if [[ -d "$SMOM_INSTALL_DIR" ]]; then
|
||
for f in "$SMOM_INSTALL_DIR"/*.sh; do
|
||
[[ -f "$f" ]] || continue
|
||
run_scp "$f" "$USER@$host:$REMOTE_DIR/install/"
|
||
done
|
||
fi
|
||
|
||
run_ssh "$host" "find $REMOTE_DIR/scripts $REMOTE_DIR/lib $REMOTE_DIR/install -name '*.sh' -exec chmod +x {} \\; 2>/dev/null; true"
|
||
log_ok "Pushed to $host"
|
||
}
|
||
|
||
download_os_templates_on_host() {
|
||
local host="$1"
|
||
log_info "Downloading OS templates on $host (pveam)..."
|
||
run_ssh "$host" "command -v pveam >/dev/null 2>&1 || { echo 'pveam not found'; exit 1; }
|
||
for t in debian-12-standard_12.12-1_amd64.tar.zst ubuntu-22.04-standard_22.04-1_amd64.tar.zst; do
|
||
pveam list local | grep -q \"\$t\" && echo \"\$t already present\" || { pveam available | grep -q \"\$t\" && pveam download local \"\$t\" || echo \"\$t not available\"; }
|
||
done"
|
||
log_ok "OS template check/download done on $host"
|
||
}
|
||
|
||
# --- Main ---
|
||
|
||
echo ""
|
||
echo "Push deployment templates to Proxmox VE hosts"
|
||
echo "Hosts: ${HOSTS[*]}"
|
||
echo "Remote: $REMOTE_DIR"
|
||
[[ "$DRY_RUN" == true ]] && echo "DRY-RUN: no changes will be made"
|
||
[[ "$DOWNLOAD_TEMPLATES" == true ]] && echo "Will run pveam download on each host after push"
|
||
echo ""
|
||
|
||
FAILED=()
|
||
for h in "${HOSTS[@]}"; do
|
||
if ! ssh -o BatchMode=yes -o ConnectTimeout=5 "$USER@$h" "exit" 2>/dev/null; then
|
||
log_warn "Cannot SSH to $h (skip). Run from a host with SSH access to Proxmox."
|
||
FAILED+=("$h")
|
||
continue
|
||
fi
|
||
push_to_host "$h"
|
||
if [[ "$DOWNLOAD_TEMPLATES" == true ]]; then
|
||
download_os_templates_on_host "$h" || true
|
||
fi
|
||
done
|
||
|
||
if [[ ${#FAILED[@]} -gt 0 ]]; then
|
||
log_warn "Skipped hosts (no SSH): ${FAILED[*]}"
|
||
exit 1
|
||
fi
|
||
|
||
echo ""
|
||
log_ok "Done. Templates and scripts are on all reachable Proxmox hosts under $REMOTE_DIR"
|
||
echo "To download LXC OS templates on each host, run: $0 --download-templates"
|
||
echo ""
|