#!/bin/bash # Create (or update) the PROD ScadaBridge db-connection "BTDB", shaped exactly like QA's. # QA (decrypted 2026-11-22, password redacted): # Server=wondersqlqa.zmr.zimmer.com;Database=BT;User Id=wonderapp;Password=***;TrustServerCertificate=True;MultiSubnetFailover=True # PROD = same string with Server=wondersqlpd.zmr.zimmer.com. # The password comes from $HISTORIAN_SQL_PASSWORD (~/.zshenv, the wonderapp login proven on PROD BT 2026-11-22). # The connection string only ever exists in a 0600 temp file and is passed with --connection-string-file. # usage: apply-btdb-connection.sh [create|update ] set -euo pipefail SBP=$1; MODE=${2:-create}; ID=${3:-} source ~/.zshenv >/dev/null 2>&1 || true : "${HISTORIAN_SQL_PASSWORD:?wonderapp password not in env}" umask 077; F=$(mktemp); trap 'rm -f "$F"' EXIT printf 'Server=wondersqlpd.zmr.zimmer.com;Database=BT;User Id=wonderapp;Password=%s;TrustServerCertificate=True;MultiSubnetFailover=True' "$HISTORIAN_SQL_PASSWORD" > "$F" if [ "$MODE" = update ]; then "$SBP" db-connection update --id "$ID" --name BTDB --connection-string-file "$F" else "$SBP" db-connection create --name BTDB --connection-string-file "$F"; fi "$SBP" db-connection list