Files
smom-dbis-138/scripts/deployment/activate-omnl-production.sh
zaragoza444 5229c2d888
Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m13s
CI/CD Pipeline / Lint and Format (push) Has been cancelled
CI/CD Pipeline / Security Scanning (push) Has been cancelled
CI/CD Pipeline / Terraform Validation (push) Has been cancelled
CI/CD Pipeline / Kubernetes Validation (push) Has been cancelled
Deploy ChainID 138 / Deploy ChainID 138 (push) Has been cancelled
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Has been cancelled
Validation / validate-genesis (push) Has been cancelled
Validation / validate-terraform (push) Has been cancelled
Validation / validate-kubernetes (push) Has been cancelled
Validation / validate-smart-contracts (push) Has been cancelled
Validation / validate-security (push) Has been cancelled
Validation / validate-documentation (push) Has been cancelled
Verify Deployment / Verify Deployment (push) Has been cancelled
fix(omnl): production blockers for M0-M4 settlement stack
Exempt dashboard read APIs from anonymous rate limits, preserve nginx-injected auth, wire chain-mint and DB env through deploy/LXC scripts, resolve M3 token addresses from registry, and harden super-admin seeding.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 06:47:20 -07:00

90 lines
3.5 KiB
Bash

#!/usr/bin/env bash
# Full OMNL production activation: deploy stack, nginx domains, LXCs, optional opening journal.
set -euo pipefail
REPO_DIR="${OMNL_BANK_ROOT:-$HOME/smom-dbis-138}"
ENV_FILE="${OMNL_BANK_ENV:-$REPO_DIR/.env}"
SEED_JOURNAL="${SEED_OFFICE24_JOURNAL:-1}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/omnl-pve-ssh.sh
source "${SCRIPT_DIR}/lib/omnl-pve-ssh.sh"
log() { echo "[$(date -Iseconds)] $*"; }
cd "$REPO_DIR"
git pull --ff-only origin main
log "=== 1/5 Deploy OMNL bank stack on dev ==="
bash scripts/deployment/deploy-omnl-bank-production.sh
log "=== 2/5 Install nginx domain routing (online + central bank + trade) ==="
bash scripts/deployment/deploy-omnl-domains.sh
log "=== 3/5 Sync banking portal LXCs (5825-5828) ==="
bash scripts/deployment/sync-ali-omnl-banking-portal-lxcs.sh --apply
log "=== 4/5 Push Fineract/API env to each LXC ==="
if [[ -f "$ENV_FILE" ]]; then
for CTID in 5825 5826 5827 5828; do
bash scripts/deployment/push-portal-env-to-lxc.sh "$CTID"
omnl_pve_ssh "pct exec ${CTID} -- bash ${OMNL_PORTAL_ROOT:-/srv/zardasht-portal}/scripts/deployment/start-omnl-banking-portal.sh" 2>/dev/null || log "WARN: portal restart failed for CT $CTID"
done
else
log "WARN: no $ENV_FILE — skip LXC Fineract env"
fi
log "=== 4b Super-admin DB seed (control panel) ==="
if [[ -f "$ENV_FILE" ]] && [[ "${SEED_SUPER_ADMIN_USERS:-1}" == "1" ]]; then
set -a
set +u
# shellcheck disable=SC1090
source "$ENV_FILE"
set -u
set +a
if [[ -n "${DATABASE_URL:-}" ]]; then
node scripts/deployment/seed-omnl-super-admin-users.mjs --stop-services | tee "$HOME/omnl-super-admin-credentials.txt" || log "WARN: super-admin user seed failed"
else
log "WARN: DATABASE_URL unset — skip super-admin user seed"
fi
fi
log "=== 5/5 Office 24 opening journal (activate live ledgers) ==="
MATERIAL_OPENING_USD="${OMNL_MATERIAL_OPENING_THRESHOLD:-10000000}"
STATUS_FILE="$REPO_DIR/config/omnl-hospitallers-office24-status.v1.json"
if [[ "$SEED_JOURNAL" == "1" ]] && [[ -f "$ENV_FILE" ]]; then
set -a
set +u
# shellcheck disable=SC1090
source "$ENV_FILE"
set -u
set +a
if [[ -f "$STATUS_FILE" ]] && grep -q '"fundingPosted"[[:space:]]*:[[:space:]]*true' "$STATUS_FILE" 2>/dev/null; then
log "Office 24 fundingPosted=true in status SSOT — skip single-leg seed (journal already live)"
elif [[ -n "${OFFICE24_OPENING_M1_USD:-}" ]]; then
opening_amt="${OFFICE24_OPENING_M1_USD//,/}"
if awk -v amt="$opening_amt" -v lim="$MATERIAL_OPENING_USD" 'BEGIN { exit !(amt >= lim) }'; then
log "Material opening amount ($OFFICE24_OPENING_M1_USD) — skip single-leg seed (use 1b canary/execute matrix)"
else
node scripts/deployment/seed-office-24-opening-journal.mjs
bash scripts/deployment/deploy-omnl-bank-production.sh
fi
else
log "OFFICE24_OPENING_M1_USD not set — ledger reads live Fineract only (no seed)"
fi
else
log "Journal seed skipped (SEED_OFFICE24_JOURNAL=$SEED_JOURNAL)"
fi
log "=== Production URLs ==="
log " Central Bank: https://secure.d-bis.org/central-bank"
log " Online banking: https://online.omdnl.org/central-bank"
log " Office 24: https://office24.omdnl.org/office-24"
log " DBIS Trade: https://exchange.d-bis.org/trade"
log " Digital Swap: https://digital.omdnl.org/swap"
log "=== Health ==="
curl -sf http://127.0.0.1:3011/api/v1/settlement/health | head -c 120 || true
echo
curl -sf http://127.0.0.1:3011/api/v1/settlement/money-supply/public | head -c 300 || true
echo
log "Activation complete"