- 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
100 lines
3.8 KiB
Bash
100 lines
3.8 KiB
Bash
#!/usr/bin/env bash
|
|
# Build the info.defi-oracle.io SPA locally and sync it into the dedicated web LXC.
|
|
#
|
|
# Default target: VMID 2410 on r630-01 (nginx-only CT). Do not deploy to VMID 2400 — that is ThirdWeb RPC.
|
|
# Provision once: scripts/deployment/provision-info-defi-oracle-web-lxc.sh
|
|
#
|
|
# Override: PROXMOX_HOST, INFO_DEFI_ORACLE_VMID (or INFO_DEFI_ORACLE_WEB_VMID from ip-addresses.conf).
|
|
|
|
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
|
|
|
|
PROXMOX_HOST="${PROXMOX_HOST:-${PROXMOX_HOST_R630_01:-192.168.11.11}}"
|
|
VMID="${INFO_DEFI_ORACLE_VMID:-${INFO_DEFI_ORACLE_WEB_VMID:-2410}}"
|
|
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_SRC="${PROJECT_ROOT}/config/nginx/info-defi-oracle-io.site.conf"
|
|
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new"
|
|
DRY_RUN=false
|
|
|
|
if [[ "${1:-}" == "--dry-run" ]]; then
|
|
DRY_RUN=true
|
|
fi
|
|
|
|
if ! command -v pnpm >/dev/null 2>&1; then
|
|
echo "pnpm is required." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v tar >/dev/null 2>&1; then
|
|
echo "tar is required." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f "$NGINX_SRC" ]]; then
|
|
echo "ERROR: Missing $NGINX_SRC" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TMP_TGZ="${TMPDIR:-/tmp}/info-defi-oracle-sync-$$.tgz"
|
|
REMOTE_TGZ="/tmp/info-defi-oracle-sync-$$.tgz"
|
|
REMOTE_NGINX="/tmp/info-defi-oracle-io-site-$$.conf"
|
|
CT_TGZ="/tmp/info-defi-oracle-sync.tgz"
|
|
cleanup() { rm -f "$TMP_TGZ"; }
|
|
trap cleanup EXIT
|
|
|
|
if $DRY_RUN; then
|
|
echo "[DRY-RUN] pnpm --filter info-defi-oracle-138 build"
|
|
echo "[DRY-RUN] tar info-defi-oracle-138/dist -> $TMP_TGZ"
|
|
echo "[DRY-RUN] scp dist tgz + nginx site -> root@${PROXMOX_HOST}"
|
|
echo "[DRY-RUN] pct push ${VMID} -> ${CT_TGZ} + site to ${SITE_FILE}"
|
|
echo "[DRY-RUN] extract to ${APP_DIR}"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Building info-defi-oracle-138..."
|
|
pnpm --filter info-defi-oracle-138 build
|
|
|
|
echo "Packaging dist/..."
|
|
tar czf "$TMP_TGZ" -C "$PROJECT_ROOT/info-defi-oracle-138/dist" .
|
|
|
|
echo "Copying package and nginx site 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 site 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/info-defi-oracle"
|
|
pct exec "$VMID" -- nginx -t
|
|
pct exec "$VMID" -- systemctl reload nginx
|
|
sleep 1
|
|
pct exec "$VMID" -- curl -fsS -H 'Host: info.defi-oracle.io' http://127.0.0.1/health >/dev/null
|
|
pct exec "$VMID" -- bash -lc "curl -fsS -H 'Host: info.defi-oracle.io' -o /tmp/info-ta-networks.json 'http://127.0.0.1/token-aggregation/api/v1/networks?refresh=1' && grep -q '\"networks\"' /tmp/info-ta-networks.json && rm -f /tmp/info-ta-networks.json"
|
|
REMOTE
|
|
|
|
echo "Done. Target: VMID ${VMID} (${IP_INFO_DEFI_ORACLE_WEB:-LAN IP from provision script}). Next steps:"
|
|
echo " 1. NPMplus: point info.defi-oracle.io → http://${IP_INFO_DEFI_ORACLE_WEB:-192.168.11.218}:80 (scripts/nginx-proxy-manager/update-npmplus-proxy-hosts-api.sh)"
|
|
echo " 2. Optional tunnel/DNS: scripts/cloudflare/set-info-defi-oracle-dns-to-vmid2400-tunnel.sh"
|
|
echo " 3. pnpm run verify:info-defi-oracle-public"
|