#!/usr/bin/env bash # Install (or remove) the nightly differential-testing run in the user's crontab (no root needed). # bash scripts/install_nightly.sh # add: every night at 02:30 # bash scripts/install_nightly.sh --remove # remove the entry set -euo pipefail cd "$(dirname "$0")/.." REPO=$(pwd) TAG="# simurg-nightly" LINE="30 2 * * * cd $REPO && flock -n /tmp/simurg-nightly.lock .venv/bin/python scripts/nightly.py >> data/nightly/cron.log 2>&1 $TAG" current=$(crontab -l 2>/dev/null | grep -v -- "$TAG" || true) if [[ "${1:-}" == "--remove" ]]; then printf '%s\n' "$current" | sed '/^$/d' | crontab - echo "nightly entry removed" exit 0 fi mkdir -p data/nightly printf '%s\n%s\n' "$current" "$LINE" | sed '/^$/d' | crontab - echo "installed: $LINE" crontab -l | grep -- "$TAG"