Files
proxmox/scripts/deployment/sync-omdnl-org-static-to-ct.sh
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains
- Omit embedded publish git dirs and empty placeholders from index

Made-with: Cursor
2026-04-12 06:12:20 -07:00

80 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Sync sites/omdnl-org/public into the dedicated nginx LXC (default VMID 10203).
#
# Provision once: scripts/deployment/provision-omdnl-org-web-lxc.sh
#
# Usage: bash scripts/deployment/sync-omdnl-org-static-to-ct.sh [--dry-run]
# Env: PROXMOX_HOST, OMDNL_ORG_WEB_VMID, IP_OMDNL_ORG_WEB (from config/ip-addresses.conf)
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="${OMDNL_ORG_WEB_VMID:-10203}"
APP_DIR="${OMDNL_ORG_WEB_ROOT:-/var/www/omdnl.org/html}"
SITE_FILE="${OMDNL_ORG_NGINX_SITE:-/etc/nginx/sites-available/omdnl-org}"
NGINX_SRC="${PROJECT_ROOT}/config/nginx/omdnl-org.site.conf"
STATIC_SRC="${PROJECT_ROOT}/sites/omdnl-org/public"
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new"
DRY_RUN=false
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true
if [[ ! -d "$STATIC_SRC" ]]; then
echo "ERROR: Missing static directory $STATIC_SRC" >&2
exit 1
fi
if [[ ! -f "$NGINX_SRC" ]]; then
echo "ERROR: Missing $NGINX_SRC" >&2
exit 1
fi
TMP_TGZ="${TMPDIR:-/tmp}/omdnl-org-sync-$$.tgz"
REMOTE_TGZ="/tmp/omdnl-org-sync-$$.tgz"
REMOTE_NGINX="/tmp/omdnl-org-site-$$.conf"
CT_TGZ="/tmp/omdnl-org-sync.tgz"
cleanup() { rm -f "$TMP_TGZ"; }
trap cleanup EXIT
if $DRY_RUN; then
echo "[DRY-RUN] tar $STATIC_SRC -> push VMID $VMID $APP_DIR"
exit 0
fi
echo "Packaging static files..."
tar czf "$TMP_TGZ" -C "$STATIC_SRC" .
echo "Copying to Proxmox host ${PROXMOX_HOST}..."
scp $SSH_OPTS "$TMP_TGZ" "root@${PROXMOX_HOST}:${REMOTE_TGZ}"
scp $SSH_OPTS "$NGINX_SRC" "root@${PROXMOX_HOST}:${REMOTE_NGINX}"
echo "Installing into VMID ${VMID}..."
ssh $SSH_OPTS "root@${PROXMOX_HOST}" bash -s "$VMID" "$REMOTE_TGZ" "$CT_TGZ" "$APP_DIR" "$SITE_FILE" "$REMOTE_NGINX" <<'REMOTE'
set -euo pipefail
VMID="$1"
REMOTE_TGZ="$2"
CT_TGZ="$3"
APP_DIR="$4"
SITE_FILE="$5"
REMOTE_NGINX="$6"
pct push "$VMID" "$REMOTE_TGZ" "$CT_TGZ"
rm -f "$REMOTE_TGZ"
pct exec "$VMID" -- bash -lc "mkdir -p '$APP_DIR' && rm -rf '$APP_DIR'/* && tar xzf '$CT_TGZ' -C '$APP_DIR' && rm -f '$CT_TGZ'"
pct push "$VMID" "$REMOTE_NGINX" "$SITE_FILE"
rm -f "$REMOTE_NGINX"
pct exec "$VMID" -- bash -lc "ln -sf '$SITE_FILE' /etc/nginx/sites-enabled/omdnl-org"
pct exec "$VMID" -- nginx -t
pct exec "$VMID" -- systemctl reload nginx
sleep 1
pct exec "$VMID" -- curl -fsS -H 'Host: omdnl.org' http://127.0.0.1/health >/dev/null
REMOTE
echo "Done. LAN: http://${IP_OMDNL_ORG_WEB:-192.168.11.222}/ (Host: omdnl.org)"
echo "Next: Cloudflare DNS + NPM — see scripts/cloudflare/configure-omdnl-org-dns.sh and upsert-omdnl-org-proxy-host.sh"