Files
MatchLiveTv/infra/scripts/install_production_cron.sh
Emiliano Frascaro da75582dae Sposta storage video su disco dedicato e completa ops/SMTP in produzione.
Recordings e Garage usano bind mount su /media/videos; aggiunge ntfy self-hosted,
notifiche critical+warning, SMTP Aruba SSL/465 e fix cron replay.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-12 23:13:08 +02:00

35 lines
1.2 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"
SCAN_LOGS="${ROOT}/scripts/cron/scan_ops_logs.sh"
LOG_DIR="${MATCHLIVETV_LOG_DIR:-/opt/matchlivetv/log}"
LOG_FILE="${LOG_DIR}/cron-replay.log"
OPS_LOG_FILE="${LOG_DIR}/cron-ops.log"
chmod +x "$RUNNER" "$SCAN_LOGS"
mkdir -p "$LOG_DIR"
MARKER="# matchlivetv-replay-cron"
CRON_BLOCK="${MARKER}
30 * * * * mkdir -p ${LOG_DIR} && ${RUNNER} recordings:cleanup_local >> ${LOG_FILE} 2>&1
0 3 * * * mkdir -p ${LOG_DIR} && ${RUNNER} recordings:purge_expired >> ${LOG_FILE} 2>&1
0 8 * * * mkdir -p ${LOG_DIR} && ${RUNNER} recordings:expiry_warnings >> ${LOG_FILE} 2>&1
*/10 * * * * mkdir -p ${LOG_DIR} && ${SCAN_LOGS} >> ${OPS_LOG_FILE} 2>&1
"
existing="$(crontab -l 2>/dev/null || true)"
filtered="$(echo "$existing" | grep -v "$MARKER" | grep -v 'run_rails_task\.sh' | grep -v 'scan_ops_logs\.sh' || true)"
if echo "$existing" | grep -q "$MARKER"; then
echo "Crontab replay già presente, aggiorno..."
fi
{
[ -n "$filtered" ] && echo "$filtered"
echo "$CRON_BLOCK"
} | sed '/^$/d' | crontab -
echo "Crontab installato:"
crontab -l | grep -A3 "$MARKER"