#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CRON="$ROOT/deploy/yokesen-workshop-notifications.cron"

[[ -f "$CRON" ]]
[[ "$(tail -c 1 "$CRON" | od -An -t u1 | tr -d ' ')" == "10" ]]
[[ "$(wc -l < "$CRON" | tr -d ' ')" == "1" ]]
grep -Fxq '* * * * * root /usr/sbin/runuser -u yokesennotify -- /usr/bin/env WORKSHOP_NOTIFICATION_ENV_FILE=/etc/yokesen/workshop-notification.env WORKSHOP_NOTIFICATION_WORKER=/opt/yokesen-platform-api-current/bin/workshop-notification-worker.php /opt/yokesen-platform-api-current/bin/run-workshop-notification-worker.sh >> /var/log/yokesen-workshop-notification.log 2>&1' "$CRON"

echo "notification_cron_unit: PASS"
