#!/bin/bash
# cPanel / Linux cron wrapper
# Example crontab (daily 08:00 server time):
#   0 8 * * * /home/USER/content_generation/cron/run.sh >> /home/USER/content_generation/storage/logs/cron.log 2>&1

set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"

# Prefer project venv if present
if [[ -x "$ROOT/.venv/bin/python" ]]; then
  PY="$ROOT/.venv/bin/python"
elif command -v python3 >/dev/null 2>&1; then
  PY="$(command -v python3)"
else
  echo "python3 not found" >&2
  exit 1
fi

exec "$PY" "$ROOT/bin/run_pipeline.py"
