#!/bin/bash # Render deploy/market-atlas.mld.json with the real secrets and push it to the mld gateway (M1M32:~/dispatch/apps/). # Usage: deploy/render-manifest.sh [--push] # Secrets (git-ignored): deploy/.admin-token (generated if missing), deploy/.hfmd-key (hfmarketdata.io API key; optional, keyless limits otherwise). set -euo pipefail cd "$(dirname "$0")/.." TOKEN_FILE=deploy/.admin-token HFMD_FILE=deploy/.hfmd-key [ -s "$TOKEN_FILE" ] || { openssl rand -hex 24 > "$TOKEN_FILE"; echo "generated $TOKEN_FILE"; } TOKEN=$(tr -d '\n' < "$TOKEN_FILE") HFMD_KEY="" [ -s "$HFMD_FILE" ] && HFMD_KEY=$(tr -d '\n' < "$HFMD_FILE") || echo "warning: $HFMD_FILE missing — hfmarketdata connector will use keyless limits" mkdir -p deploy/rendered sed -e "s/{{ADMIN_TOKEN}}/$TOKEN/g" -e "s#{{HFMD_KEY}}#$HFMD_KEY#g" deploy/market-atlas.mld.json > deploy/rendered/market-atlas.json python3 -c "import json; json.load(open('deploy/rendered/market-atlas.json')); print('manifest ok')" if [ "${1:-}" = "--push" ]; then scp -q deploy/rendered/market-atlas.json M1M32:~/dispatch/apps/market-atlas.json ssh M1M32 'chmod 600 ~/dispatch/apps/market-atlas.json && echo "pushed to M1M32:~/dispatch/apps/market-atlas.json"' fi