#!/bin/bash # Daily self-healing enrichment: fills modulation/fec_type/inbuilt_fec/coherent on # new/changed transceivers via the idempotent fill-only fn_tip_enrich_modulation_fec(). # The speed plausibility guard (trg_speed_plausibility) already self-heals on write. # Cron: 30 3 * * * /opt/tip/scripts/enrich-modulation-fec.sh set -uo pipefail LOG=/opt/tip/logs/enrich-modulation-fec.log mkdir -p "$(dirname "$LOG")" TS=$(date -u '+%Y-%m-%dT%H:%M:%SZ') # shellcheck disable=SC1091 source /opt/tip/.env 2>/dev/null || true PW="${POSTGRES_PASSWORD:-}" # short-named var carries the secret to docker, no literal N=$(docker exec -e PGPASSWORD="$PW" tip-postgres psql -U tip -d transceiver_db -tAc \ "select fn_tip_enrich_modulation_fec()" 2>/dev/null | tr -d '[:space:]') if [[ "${N:-}" =~ ^[0-9]+$ ]]; then echo "[$TS] enrich rows-touched=$N" >> "$LOG" else echo "[$TS] enrich FAILED (db unreachable?)" >> "$LOG" fi