#!/usr/bin/env bash # OMNL — Config drift: output sha256 hashes of payment types, GL (1410/2100/2410), office 20 config. # Compare output to a baseline to detect drift. For CI or alerting. # Usage: bash scripts/omnl/omnl-config-hash.sh; store output as baseline and diff on next run. set -euo pipefail REPO_ROOT="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" if [ -f "${REPO_ROOT}/omnl-fineract/.env" ]; then set +u source "${REPO_ROOT}/omnl-fineract/.env" 2>/dev/null || true set -u fi BASE_URL="${OMNL_FINERACT_BASE_URL:-}" TENANT="${OMNL_FINERACT_TENANT:-omnl}" USER="${OMNL_FINERACT_USER:-app.omnl}" PASS="${OMNL_FINERACT_PASSWORD:-}" [ -z "$BASE_URL" ] || [ -z "$PASS" ] && { echo "{}"; exit 0; } CURL_OPTS=(-s -S -H "Fineract-Platform-TenantId: ${TENANT}" -H "Content-Type: application/json" -u "${USER}:${PASS}") pt=$(curl "${CURL_OPTS[@]}" "${BASE_URL}/paymenttypes" 2>/dev/null) gl=$(curl "${CURL_OPTS[@]}" "${BASE_URL}/glaccounts" 2>/dev/null) offices=$(curl "${CURL_OPTS[@]}" "${BASE_URL}/offices" 2>/dev/null) pt_hash=$(echo "$pt" | jq -c 'sort_by(.id)' 2>/dev/null | sha256sum | awk '{print $1}') gl_relevant=$(echo "$gl" | jq '[.[] | select(.glCode == "1410" or .glCode == "2100" or .glCode == "2410")] | sort_by(.id)' 2>/dev/null) gl_hash=$(echo "$gl_relevant" | sha256sum | awk '{print $1}') o20=$(echo "$offices" | jq '.[] | select(.id == 20)' 2>/dev/null) o20_hash=$(echo "$o20" | sha256sum | awk '{print $1}') echo "{\"paymentTypes\": \"$pt_hash\", \"glRelevant\": \"$gl_hash\", \"office20\": \"$o20_hash\", \"timestamp\": \"$(date -u -Iseconds)\"}"