Files
proxmox/scripts/deployment/provision-info-defi-oracle-web-lxc.sh
defiQUG 075a9c8a3c feat: deploy MEV Control GUI to mev.defi-oracle.io (nginx, NPM, Cloudflare)
- Add nginx site template + sync-mev-control-gui-defi-oracle.sh
- NPM fleet: mev.defi-oracle.io + www.mev; Cloudflare set-mev-defi-oracle-dns.sh
- ip-addresses + .env.master.example: MEV_ADMIN_API_* and web root vars
- Runbook MEV_CONTROL_DEFI_ORACLE_IO_DEPLOYMENT.md; AGENTS, MASTER_INDEX, ALL_VMIDS

Made-with: Cursor
2026-04-12 18:48:02 -07:00

88 lines
4.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Dedicated LXC for static web: info.defi-oracle.io (nginx + SPA root).
# Do not use VMID 2400 (ThirdWeb RPC); use this CT + sync-info-defi-oracle-to-vmid2400.sh.
#
# Defaults: VMID 2410, 192.168.11.218, Proxmox r630-01 (override PROXMOX_HOST for ml110).
#
# Usage (from dev machine with SSH to Proxmox):
# bash scripts/deployment/provision-info-defi-oracle-web-lxc.sh [--dry-run]
# Then:
# bash scripts/deployment/sync-info-defi-oracle-to-vmid2400.sh
# bash scripts/nginx-proxy-manager/update-npmplus-proxy-hosts-api.sh
# pnpm run verify:info-defi-oracle-public
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
# shellcheck source=/dev/null
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
PROXMOX_HOST="${PROXMOX_HOST:-${PROXMOX_HOST_R630_01:-192.168.11.11}}"
VMID="${INFO_DEFI_ORACLE_WEB_VMID:-${INFO_DEFI_ORACLE_VMID:-2410}}"
IP_CT="${IP_INFO_DEFI_ORACLE_WEB:-192.168.11.218}"
HOSTNAME_CT="${INFO_DEFI_ORACLE_WEB_HOSTNAME:-info-defi-oracle-web}"
APP_DIR="${INFO_DEFI_ORACLE_WEB_ROOT:-/var/www/info.defi-oracle.io/html}"
SITE_FILE="${INFO_DEFI_ORACLE_NGINX_SITE:-/etc/nginx/sites-available/info-defi-oracle}"
NGINX_TEMPLATE="${PROJECT_ROOT}/config/nginx/info-defi-oracle-io.site.conf"
TEMPLATE_CT="${TEMPLATE:-local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst}"
STORAGE="${STORAGE:-local-lvm}"
NETWORK="${NETWORK:-vmbr0}"
GATEWAY="${NETWORK_GATEWAY:-192.168.11.1}"
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new"
DRY_RUN=false
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true
if [[ ! -f "$NGINX_TEMPLATE" ]]; then
echo "ERROR: Missing $NGINX_TEMPLATE" >&2
exit 1
fi
echo "=== Provision info.defi-oracle.io web LXC ==="
echo "Proxmox: ${PROXMOX_HOST} VMID: ${VMID} IP: ${IP_CT}"
if $DRY_RUN; then
echo "[DRY-RUN] pct create ${VMID} if missing, apt nginx, install ${SITE_FILE}, enable site"
exit 0
fi
if ssh $SSH_OPTS "root@${PROXMOX_HOST}" "pct list 2>/dev/null | grep -q '^${VMID} '"; then
echo "CT ${VMID} already exists — skipping pct create"
else
echo "Creating CT ${VMID} (${HOSTNAME_CT}) @ ${IP_CT}/24..."
ssh $SSH_OPTS "root@${PROXMOX_HOST}" bash -s <<EOF
set -euo pipefail
pct create ${VMID} ${TEMPLATE_CT} \\
--hostname ${HOSTNAME_CT} \\
--memory 1024 \\
--cores 1 \\
--rootfs ${STORAGE}:8 \\
--net0 name=eth0,bridge=${NETWORK},ip=${IP_CT}/24,gw=${GATEWAY} \\
--nameserver ${DNS_PRIMARY:-1.1.1.1} \\
--description 'Dedicated nginx static host: info.defi-oracle.io (Chain 138 SPA)' \\
--start 1 \\
--onboot 1 \\
--unprivileged 1
EOF
echo "Waiting for CT to boot..."
sleep 15
fi
ssh $SSH_OPTS "root@${PROXMOX_HOST}" "pct status ${VMID}" | grep -q running || {
echo "ERROR: CT ${VMID} not running — start with: ssh root@${PROXMOX_HOST} 'pct start ${VMID}'" >&2
exit 1
}
echo "Installing nginx inside CT ${VMID}..."
ssh $SSH_OPTS "root@${PROXMOX_HOST}" "pct exec ${VMID} -- bash -lc \"set -euo pipefail; export DEBIAN_FRONTEND=noninteractive; apt-get update -qq; apt-get install -y -qq nginx ca-certificates curl; mkdir -p '${APP_DIR}'; rm -f /etc/nginx/sites-enabled/default; systemctl enable nginx\""
echo "Installing nginx site config..."
scp $SSH_OPTS "$NGINX_TEMPLATE" "root@${PROXMOX_HOST}:/tmp/info-defi-oracle-io.site.conf"
ssh $SSH_OPTS "root@${PROXMOX_HOST}" "pct push ${VMID} /tmp/info-defi-oracle-io.site.conf ${SITE_FILE} && rm -f /tmp/info-defi-oracle-io.site.conf"
ssh $SSH_OPTS "root@${PROXMOX_HOST}" "pct exec ${VMID} -- bash -lc \"ln -sf '${SITE_FILE}' /etc/nginx/sites-enabled/info-defi-oracle && nginx -t && systemctl reload nginx && sleep 1 && curl -fsS -H 'Host: info.defi-oracle.io' http://127.0.0.1/health >/dev/null\""
echo ""
echo "✅ Dedicated web LXC ${VMID} ready at ${IP_CT}:80"
echo " Next: bash scripts/deployment/sync-info-defi-oracle-to-vmid2400.sh"
echo " MEV Control: bash scripts/deployment/sync-mev-control-gui-defi-oracle.sh (mev.defi-oracle.io; set MEV_ADMIN_API_HOST)"
echo " NPM: point info.defi-oracle.io → http://${IP_CT}:80 (fleet: update-npmplus-proxy-hosts-api.sh)"