Evita il riempimento disco da segmenti MediaMTX post-sessione con cron orario; documenta come board, overlay e regolamenti sportivi si relazionano nel sistema. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Installa crontab replay su server produzione (utente corrente).
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
RUNNER="${ROOT}/scripts/cron/run_rails_task.sh"
|
|
LOG_DIR="${MATCHLIVETV_LOG_DIR:-/opt/matchlivetv/log}"
|
|
LOG_FILE="${LOG_DIR}/cron-replay.log"
|
|
|
|
chmod +x "$RUNNER"
|
|
mkdir -p "$LOG_DIR"
|
|
|
|
MARKER="# matchlivetv-replay-cron"
|
|
CRON_BLOCK="${MARKER}
|
|
30 * * * * ${RUNNER} recordings:cleanup_local >> ${LOG_FILE} 2>&1
|
|
0 3 * * * ${RUNNER} recordings:purge_expired >> ${LOG_FILE} 2>&1
|
|
0 8 * * * ${RUNNER} recordings:expiry_warnings >> ${LOG_FILE} 2>&1
|
|
"
|
|
|
|
existing="$(crontab -l 2>/dev/null || true)"
|
|
if echo "$existing" | grep -q "$MARKER"; then
|
|
echo "Crontab replay già presente, aggiorno..."
|
|
echo "$existing" | awk -v block="$CRON_BLOCK" '
|
|
BEGIN { skip=0 }
|
|
/# matchlivetv-replay-cron/ { skip=1; next }
|
|
skip && /^[^#]/ && $0 !~ /^$/ { skip=0 }
|
|
skip { next }
|
|
{ print }
|
|
END { print block }
|
|
' | crontab -
|
|
else
|
|
(echo "$existing"; echo "$CRON_BLOCK") | crontab -
|
|
fi
|
|
|
|
echo "Crontab installato:"
|
|
crontab -l | grep -A3 "$MARKER"
|