Add optional Cosmos/Engine-X/act-runner templates, CWUSDC/EI-matrix tooling, non-EVM route planner in multi-chain-execution (tests passing), token list and extraction updates, and documentation (MetaMask matrix, GRU/CWUSDC packets). Ignore institutional evidence tarballs/sha256 under reports/status. Validated with: bash scripts/verify/run-all-validation.sh --skip-genesis Co-authored-by: Cursor <cursoragent@cursor.com>
128 lines
5.9 KiB
Bash
Executable File
128 lines
5.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Sync Gov Portals monorepo from Gitea to CT 7804 (gov-portals-dev), install deps,
|
|
# build DBIS + ICCC (and OMNL/XOM when they define a "build" script), restart systemd units.
|
|
#
|
|
# CT 7804 typically runs on r630-04 (192.168.11.14); tarball deploys omit .git, so
|
|
# in-container "git pull" is not enough — this script refreshes a local clone then
|
|
# streams the tree into the container.
|
|
#
|
|
# Usage (from proxmox repo root):
|
|
# export GITEA_TOKEN=... # or ensure it is in .env (see .env.master.example)
|
|
# bash scripts/deployment/sync-gov-portals-ct-7804-from-git.sh
|
|
#
|
|
# Options:
|
|
# --skip-fetch Use GOV_PORTALS_SOURCE as-is (no git fetch; no token required)
|
|
# --dry-run Print steps only
|
|
#
|
|
# Env:
|
|
# GOV_PORTALS_SOURCE Default: /home/intlc/projects/gov-portals-monorepo
|
|
# GOV_PORTALS_REPO_URL Default: https://gitea.d-bis.org/Gov_Web_Portals/gov-portals-monorepo.git
|
|
# GOV_PORTALS_REF Default: main
|
|
# PROXMOX_HOST / DBIS_PORTAL_PROXMOX_HOST / PROXMOX_HOST_GOV_PORTALS Default: 192.168.11.14
|
|
# VMID_GOV_PORTALS Default: 7804
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
# shellcheck disable=SC1090
|
|
source "$PROJECT_ROOT/config/ip-addresses.conf" 2>/dev/null || true
|
|
# shellcheck disable=SC1090
|
|
[ -f "$PROJECT_ROOT/.env" ] && set +u && source "$PROJECT_ROOT/.env" 2>/dev/null || true && set -u
|
|
|
|
GOV_PORTALS_SOURCE="${GOV_PORTALS_SOURCE:-/home/intlc/projects/gov-portals-monorepo}"
|
|
GOV_PORTALS_REPO_URL="${GOV_PORTALS_REPO_URL:-https://gitea.d-bis.org/Gov_Web_Portals/gov-portals-monorepo.git}"
|
|
GOV_PORTALS_REF="${GOV_PORTALS_REF:-main}"
|
|
VMID_GOV_PORTALS="${VMID_GOV_PORTALS:-7804}"
|
|
PROXMOX_HOST="${DBIS_PORTAL_PROXMOX_HOST:-${PROXMOX_HOST_GOV_PORTALS:-192.168.11.14}}"
|
|
|
|
SKIP_FETCH=false
|
|
DRY_RUN=false
|
|
for arg in "$@"; do
|
|
[[ "$arg" == "--skip-fetch" ]] && SKIP_FETCH=true
|
|
[[ "$arg" == "--dry-run" ]] && DRY_RUN=true
|
|
done
|
|
|
|
die() { echo "ERROR: $*" >&2; exit 1; }
|
|
log() { echo "[$(date +%H:%M:%S)] $*"; }
|
|
|
|
[[ -d "$GOV_PORTALS_SOURCE" ]] || die "GOV_PORTALS_SOURCE is not a directory: $GOV_PORTALS_SOURCE"
|
|
|
|
git_auth_args=()
|
|
if [[ -n "${GITEA_TOKEN:-}" ]]; then
|
|
git_auth_args=(-c "http.extraHeader=Authorization: token ${GITEA_TOKEN}")
|
|
fi
|
|
|
|
if [[ "$SKIP_FETCH" != "true" ]]; then
|
|
[[ -d "$GOV_PORTALS_SOURCE/.git" ]] || die "Not a git clone: $GOV_PORTALS_SOURCE (use --skip-fetch to rsync only)"
|
|
if [[ ${#git_auth_args[@]} -eq 0 ]]; then
|
|
die "GITEA_TOKEN is unset. Add it to $PROJECT_ROOT/.env or run: export GITEA_TOKEN=... (Or use --skip-fetch.)"
|
|
fi
|
|
if [[ "$DRY_RUN" == "true" ]]; then
|
|
log "DRY: would git fetch $GOV_PORTALS_REF and submodule update in $GOV_PORTALS_SOURCE"
|
|
else
|
|
log "Fetching $GOV_PORTALS_REF and updating submodules in $GOV_PORTALS_SOURCE"
|
|
git -C "$GOV_PORTALS_SOURCE" "${git_auth_args[@]}" fetch origin
|
|
git -C "$GOV_PORTALS_SOURCE" reset --hard "origin/$GOV_PORTALS_REF"
|
|
git -C "$GOV_PORTALS_SOURCE" "${git_auth_args[@]}" submodule update --init --recursive --force
|
|
log "Monorepo HEAD: $(git -C "$GOV_PORTALS_SOURCE" log -1 --oneline)"
|
|
if [[ -e "$GOV_PORTALS_SOURCE/DBIS/.git" ]]; then
|
|
log "DBIS HEAD: $(git -C "$GOV_PORTALS_SOURCE/DBIS" log -1 --oneline)"
|
|
fi
|
|
fi
|
|
else
|
|
log "Skipping git fetch (--skip-fetch)"
|
|
fi
|
|
|
|
SYNC_ID="gov-portals-ct-${VMID_GOV_PORTALS}-$(date +%s)"
|
|
REMOTE_SYNC="/tmp/$SYNC_ID"
|
|
|
|
if [[ "$DRY_RUN" == "true" ]]; then
|
|
log "DRY: would rsync to root@$PROXMOX_HOST:$REMOTE_SYNC/ and tar into CT $VMID_GOV_PORTALS"
|
|
exit 0
|
|
fi
|
|
|
|
log "Rsync to $PROXMOX_HOST:$REMOTE_SYNC/"
|
|
rsync -az --delete \
|
|
--exclude 'node_modules' --exclude '.next' --exclude '.git' \
|
|
--exclude '*/node_modules' --exclude '*/.next' --exclude '*/.git' \
|
|
"$GOV_PORTALS_SOURCE/" "root@$PROXMOX_HOST:$REMOTE_SYNC/"
|
|
|
|
run_pve() {
|
|
ssh -o ConnectTimeout=20 -o StrictHostKeyChecking=accept-new "root@$PROXMOX_HOST" "$@"
|
|
}
|
|
|
|
VMID="$VMID_GOV_PORTALS"
|
|
|
|
run_pve "pct exec $VMID -- mkdir -p /srv/gov-portals /tmp/gov-env-7804"
|
|
for portal in DBIS ICCC; do
|
|
for f in .env .env.local .env.production; do
|
|
run_pve "pct exec $VMID -- bash -c '[ -f /srv/gov-portals/${portal}/${f} ] && cp -a /srv/gov-portals/${portal}/${f} /tmp/gov-env-7804/${portal}_${f} || true'"
|
|
done
|
|
done
|
|
|
|
run_pve "pct exec $VMID -- bash -c 'if [ -d /srv/gov-portals ]; then find /srv/gov-portals -mindepth 1 -maxdepth 1 -exec rm -rf {} +; else mkdir -p /srv/gov-portals; fi'"
|
|
|
|
run_pve "bash -c 'cd $REMOTE_SYNC && tar cf - . | pct exec $VMID -- tar xf - -C /srv/gov-portals'"
|
|
|
|
for portal in DBIS ICCC; do
|
|
for f in .env .env.local .env.production; do
|
|
run_pve "pct exec $VMID -- bash -c '[ -f /tmp/gov-env-7804/${portal}_${f} ] && [ ! -f /srv/gov-portals/${portal}/${f} ] && cp -a /tmp/gov-env-7804/${portal}_${f} /srv/gov-portals/${portal}/${f} || true'"
|
|
done
|
|
done
|
|
|
|
run_pve "pct exec $VMID -- bash -lc 'export PATH=/usr/local/bin:/usr/bin:/bin:\$PATH; cd /srv/gov-portals && (pnpm install --frozen-lockfile || pnpm install)'"
|
|
|
|
run_pve "pct exec $VMID -- bash -lc 'export PATH=/usr/local/bin:/usr/bin:/bin:\$PATH; cd /srv/gov-portals/DBIS && pnpm run build && systemctl restart gov-portal-DBIS'"
|
|
|
|
run_pve "pct exec $VMID -- bash -lc 'export PATH=/usr/local/bin:/usr/bin:/bin:\$PATH; cd /srv/gov-portals/ICCC && pnpm run build && systemctl restart gov-portal-ICCC'"
|
|
|
|
run_pve "pct exec $VMID -- bash -lc 'export PATH=/usr/local/bin:/usr/bin:/bin:\$PATH; for p in OMNL XOM; do d=/srv/gov-portals/\$p; if [ -f \"\$d/package.json\" ] && grep -qF \"\\\"build\\\"\" \"\$d/package.json\" 2>/dev/null; then (cd \"\$d\" && pnpm run build && systemctl restart gov-portal-\$p) || true; fi; done'"
|
|
|
|
run_pve "pct exec $VMID -- bash -lc 'systemctl is-active gov-portal-DBIS gov-portal-ICCC gov-portal-OMNL gov-portal-XOM || true; printf DBIS:; curl -s -o /dev/null -w %{http_code} http://127.0.0.1:3001/; echo; printf ICCC:; curl -s -o /dev/null -w %{http_code} http://127.0.0.1:3002/; echo'"
|
|
|
|
run_pve "rm -rf $REMOTE_SYNC"
|
|
log "Removed $PROXMOX_HOST:$REMOTE_SYNC"
|
|
|
|
log "Done. CT $VMID_GOV_PORTALS on $PROXMOX_HOST updated."
|