Files
proxmox/scripts/recreate-ct-2301.sh

36 lines
1.5 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Recreate CT 2301 (besu-rpc-private-1) after corrupted rootfs
# Uses config - no hardcoded IPs. Destroys and recreates - DATA LOSS.
# Version: 2026-01-31
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/lib/load-project-env.sh"
VMID=2301
PROXMOX_HOST="$(get_host_for_vmid "$VMID")"
SSH_OPTS="-o ConnectTimeout=30 -o ServerAliveInterval=60 -o ServerAliveCountMax=3"
# Config validation (gateway defaults to 192.168.11.1 per config/ip-addresses.conf)
IP="${RPC_PRIVATE_1:-}"
GATEWAY="${NETWORK_GATEWAY:-192.168.11.1}"
[[ -z "$IP" ]] && err_exit "RPC_PRIVATE_1 not set (source config/ip-addresses.conf)"
TEMPLATE="${TEMPLATE:-local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst}"
STORAGE="${STORAGE:-local-lvm}"
NETWORK="${NETWORK:-vmbr0}"
echo "=== Recreate CT 2301 (besu-rpc-private-1) ==="
echo "Host: $PROXMOX_HOST | IP: $IP"
echo "WARNING: This DESTROYS the container and all data."
[[ "${1:-}" != "--yes" ]] && { read -p "Type 'yes' to proceed: " r; [[ "$r" != "yes" ]] && exit 1; }
echo "Destroying CT $VMID..."
ssh $SSH_OPTS root@"$PROXMOX_HOST" "pct destroy $VMID --purge 1" 2>/dev/null || true
echo "Creating new CT $VMID..."
ssh $SSH_OPTS root@"$PROXMOX_HOST" "pct create $VMID $TEMPLATE --hostname besu-rpc-private-1 --memory 16384 --cores 4 --rootfs $STORAGE:200 --net0 name=eth0,bridge=$NETWORK,ip=$IP/24,gw=$GATEWAY --description 'Besu RPC Private Node' --start 1 --onboot 1 --unprivileged 0"
echo "Done. Next: install Besu and config (copy from 2101/2201)."