diff --git a/config/omnl-banking-portal-host.v1.json b/config/omnl-banking-portal-host.v1.json index 7171d8b..9370d4f 100644 --- a/config/omnl-banking-portal-host.v1.json +++ b/config/omnl-banking-portal-host.v1.json @@ -12,7 +12,8 @@ "proxmox": { "host": "192.168.11.13", "access": "ssh root@192.168.11.13 then pct exec ", - "bankingLxcRange": "5820-5828", + "bankingLxcRange": "5825-5828", + "bankingLxcConfig": "config/omnl-banking-portal-lxcs.v1.json", "exampleCtid": 5825 }, "bankingLxc": { diff --git a/config/omnl-banking-portal-lxcs.v1.json b/config/omnl-banking-portal-lxcs.v1.json new file mode 100644 index 0000000..6bb2965 --- /dev/null +++ b/config/omnl-banking-portal-lxcs.v1.json @@ -0,0 +1,31 @@ +{ + "version": "1.0.0", + "description": "Banking portal LXCs on Proxmox r630-03 (192.168.11.13). NPMplus maps nine public FQDNs to these four stacks.", + "pveHost": "192.168.11.13", + "pveNode": "r630-03", + "portalRoot": "/srv/ali-portal", + "containers": [ + { + "ctid": 5825, + "name": "omnl-office24-portal", + "products": ["office-24", "digital-swap"] + }, + { + "ctid": 5826, + "name": "dbis-exchange-portal", + "products": ["dbis-trade"] + }, + { + "ctid": 5827, + "name": "dbis-secure-portal", + "products": ["central-bank", "online-banking"] + }, + { + "ctid": 5828, + "name": "dbis-forex-portal", + "products": ["forex-trade"] + } + ], + "legacyPlannedCtids": [5820, 5821, 5822, 5823, 5824], + "notes": "5820–5824 are not provisioned on r630-03; use these four running CTIDs for sync." +} diff --git a/scripts/deployment/deploy-omnl-banking-portal-pct.sh b/scripts/deployment/deploy-omnl-banking-portal-pct.sh index f76f67b..d06bcc9 100755 --- a/scripts/deployment/deploy-omnl-banking-portal-pct.sh +++ b/scripts/deployment/deploy-omnl-banking-portal-pct.sh @@ -24,6 +24,11 @@ pve_exec() { omnl_pve_preflight +if ! omnl_pve_ensure_ct_running "$CTID"; then + log "Skip CT ${CTID} — not available on PVE" + exit 2 +fi + if [[ "${OMNL_SKIP_BUILD:-0}" != "1" ]]; then log "Building OMNL stack at $REPO_DIR..." cd "$REPO_DIR" diff --git a/scripts/deployment/lib/omnl-pve-ssh.sh b/scripts/deployment/lib/omnl-pve-ssh.sh index 58fdd99..24d5696 100755 --- a/scripts/deployment/lib/omnl-pve-ssh.sh +++ b/scripts/deployment/lib/omnl-pve-ssh.sh @@ -57,3 +57,26 @@ omnl_pve_preflight() { return 1 } } + +omnl_pve_ensure_ct_running() { + local ctid="$1" + local status + status="$(omnl_pve_ssh "pct status ${ctid} 2>/dev/null || true")" + if [[ -z "$status" ]]; then + echo "CT ${ctid} does not exist on ${OMNL_PVE_SSH_TARGET} — skip" >&2 + return 1 + fi + if [[ "$status" == *"status: running"* ]]; then + return 0 + fi + if [[ "$status" == *"status: stopped"* ]]; then + log_msg "Starting stopped CT ${ctid}..." + omnl_pve_ssh "pct start ${ctid}" + sleep 3 + return 0 + fi + echo "CT ${ctid} is not runnable (${status})" >&2 + return 1 +} + +log_msg() { echo "[$(date -Iseconds)] $*" >&2; } diff --git a/scripts/deployment/sync-ali-omnl-banking-portal-lxcs.sh b/scripts/deployment/sync-ali-omnl-banking-portal-lxcs.sh index 27ba297..dd5dae0 100755 --- a/scripts/deployment/sync-ali-omnl-banking-portal-lxcs.sh +++ b/scripts/deployment/sync-ali-omnl-banking-portal-lxcs.sh @@ -1,17 +1,16 @@ #!/usr/bin/env bash -# Sync OMNL banking portal to all Ali banking LXCs (5820–5828) via Proxmox pct. +# Sync OMNL banking portal to banking LXCs via Proxmox pct. set -euo pipefail REPO_DIR="${OMNL_BANK_ROOT:-$HOME/smom-dbis-138}" DEPLOY_SCRIPT="${REPO_DIR}/scripts/deployment/deploy-omnl-banking-portal-pct.sh" +LXC_CONFIG="${OMNL_BANKING_LXC_CONFIG:-$REPO_DIR/config/omnl-banking-portal-lxcs.v1.json}" APPLY=false if [[ "${1:-}" == "--apply" ]]; then APPLY=true fi -CTIDS=(5820 5821 5822 5823 5824 5825 5826 5827 5828) - log() { echo "[$(date -Iseconds)] $*"; } if [[ ! -f "$DEPLOY_SCRIPT" ]]; then @@ -19,6 +18,24 @@ if [[ ! -f "$DEPLOY_SCRIPT" ]]; then exit 1 fi +read_ctids() { + if [[ -n "${OMNL_BANKING_LXC_CTIDS:-}" ]]; then + # shellcheck disable=SC2206 + CTIDS=(${OMNL_BANKING_LXC_CTIDS}) + return + fi + if command -v node >/dev/null 2>&1 && [[ -f "$LXC_CONFIG" ]]; then + mapfile -t CTIDS < <(node -e " + const c=require(process.argv[1]); + for (const x of c.containers||[]) console.log(x.ctid); + " "$LXC_CONFIG") + return + fi + CTIDS=(5825 5826 5827 5828) +} + +read_ctids + # shellcheck source=lib/omnl-pve-ssh.sh source "${REPO_DIR}/scripts/deployment/lib/omnl-pve-ssh.sh" omnl_pve_preflight @@ -26,6 +43,7 @@ omnl_pve_preflight log "OMNL banking LXC sync — CTIDs: ${CTIDS[*]}" log "Mode: $(if $APPLY; then echo APPLY; else echo DRY-RUN; fi)" log "Repo: $REPO_DIR" +log "Config: $LXC_CONFIG" log "PVE: ${OMNL_PVE_SSH_TARGET} (sudo prefix: ${OMNL_PVE_SSH_PREFIX[*]:-none})" if $APPLY; then @@ -34,17 +52,29 @@ if $APPLY; then bash scripts/deployment/deploy-omnl-bank-production.sh fi +synced=0 +skipped=0 for CTID in "${CTIDS[@]}"; do if $APPLY; then log "Deploying CT $CTID..." + set +e OMNL_SKIP_BUILD=1 OMNL_PCT_CTID="$CTID" OMNL_BANK_ROOT="$REPO_DIR" bash "$DEPLOY_SCRIPT" + rc=$? + set -e + if [[ $rc -eq 0 ]]; then + synced=$((synced + 1)) + elif [[ $rc -eq 2 ]]; then + skipped=$((skipped + 1)) + else + log "WARN: deploy failed for CT $CTID (exit $rc, continuing)" + fi else log "Would deploy CT $CTID → /srv/ali-portal (pct exec on ${OMNL_PVE_SSH_TARGET})" fi done if $APPLY; then - log "All ${#CTIDS[@]} banking LXCs synced." + log "Synced ${synced}/${#CTIDS[@]} banking LXCs (${skipped} skipped)." else log "Dry-run complete. Re-run with --apply to deploy." fi