55 lines
1.6 KiB
Bash
55 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Create placeholder LXCs for the DBIS RTGS control plane.
|
|
# Usage:
|
|
# ./scripts/deployment/create-dbis-rtgs-control-plane-lxcs.sh [--dry-run]
|
|
|
|
HOST="${PROXMOX_HOST_R630_02:-192.168.11.12}"
|
|
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new"
|
|
TEMPLATE="${PVE_LXC_TEMPLATE:-local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst}"
|
|
STORAGE="${PVE_STORAGE:-local-lvm}"
|
|
BRIDGE="${PVE_BRIDGE:-vmbr0}"
|
|
GATEWAY="${PVE_GATEWAY:-192.168.11.1}"
|
|
|
|
DRY_RUN=false
|
|
if [[ "${1:-}" == "--dry-run" ]]; then
|
|
DRY_RUN=true
|
|
fi
|
|
|
|
LXCS=(
|
|
"${RTGS_ORCH_VMID:-5805} ${RTGS_ORCH_HOSTNAME:-rtgs-orchestrator-1} ${RTGS_ORCH_IP:-192.168.11.93} 4096 2 24"
|
|
"${RTGS_FX_VMID:-5806} ${RTGS_FX_HOSTNAME:-rtgs-fx-1} ${RTGS_FX_IP:-192.168.11.94} 4096 2 24"
|
|
"${RTGS_LIQ_VMID:-5807} ${RTGS_LIQ_HOSTNAME:-rtgs-liquidity-1} ${RTGS_LIQ_IP:-192.168.11.95} 4096 2 24"
|
|
)
|
|
|
|
run_remote() {
|
|
local cmd="$1"
|
|
if $DRY_RUN; then
|
|
echo "[DRY-RUN] $cmd"
|
|
else
|
|
ssh $SSH_OPTS "root@$HOST" "$cmd"
|
|
fi
|
|
}
|
|
|
|
echo "=== DBIS RTGS control-plane LXCs ==="
|
|
echo "Host: $HOST"
|
|
echo "Template: $TEMPLATE"
|
|
echo
|
|
|
|
for spec in "${LXCS[@]}"; do
|
|
read -r vmid hostname ip memory cores disk <<<"$spec"
|
|
cmd="pct create $vmid $TEMPLATE \
|
|
--hostname $hostname \
|
|
--cores $cores \
|
|
--memory $memory \
|
|
--rootfs ${STORAGE}:${disk} \
|
|
--net0 name=eth0,bridge=${BRIDGE},gw=${GATEWAY},ip=${ip}/24 \
|
|
--onboot 1 \
|
|
--unprivileged 1 \
|
|
--features nesting=1 \
|
|
--password \$(openssl rand -base64 18) \
|
|
--description 'DBIS RTGS control-plane LXC ($hostname)'"
|
|
run_remote "$cmd"
|
|
done
|