#!/usr/bin/env bash # Install system-level scheduled tasks (run as root on the deployment server) # Usage: sudo ./scripts/cron-install.sh # # Writes two /etc/cron.d files: # 1. pyrigs-certbot - certificate renewal check, daily at 03:00 / 15:00 # 2. pyrigs-django - cleanup and reminder jobs inside the pyrigs container set -euo pipefail REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" CERTBOT_CRON="/etc/cron.d/pyrigs-certbot" DJANGO_CRON="/etc/cron.d/pyrigs-django" # 1. Certificate renewal: checked twice a day (officially recommended frequency); # on successful renewal the deploy-hook in the official hook dir takes over cat > "$CERTBOT_CRON" < "$DJANGO_CRON" <> /var/log/pyrigs-cleanup.log 2>&1 0 8 * * * root docker compose -f $REPO_DIR/compose.yml exec -T pyrigs python manage.py send_reminders >> /var/log/pyrigs-reminders.log 2>&1 EOF chmod 644 "$CERTBOT_CRON" "$DJANGO_CRON" echo "Installed:" echo " $CERTBOT_CRON" echo " $DJANGO_CRON"