caldav-email-reminders/entrypoint.sh
2025-05-01 17:04:01 -05:00

57 lines
2.1 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
set -e
# ─── Map / export all of your .env into what the Python scripts expect ─────────
# CalDAV (your .env uses CALDAV_BASE_URL and CALDAV_CALENDARS)
export CALDAV_BASE="$CALDAV_BASE_URL"
export CALENDAR_URLS="$CALDAV_CALENDARS"
# credentials
export CALDAV_USERNAME
export CALDAV_PASSWORD
# sync settings
export FETCH_WINDOW_DAYS="${FETCH_WINDOW_DAYS:-90}"
export DB_PATH="${DB_PATH:-/data/sync_state.db}"
export RETENTION_DAYS="${RETENTION_DAYS:-30}"
# SMTP / dispatch settings (already in env from --env-file)
export SMTP_HOST
export SMTP_PORT
export SMTP_USERNAME
export SMTP_PASSWORD
export SMTP_USE_TLS
export SMTP_USE_STARTTLS
export EMAIL_FROM
export EMAIL_TO
export EMAIL_SUBJECT_PREFIX
# optional override intervals (in seconds)
: "${SYNC_INTERVAL:=300}" # default 5min
: "${DISPATCH_INTERVAL:=60}" # default 1min
# ─── Initial run so you dont have to wait ────────────────────────────────────
echo "[entrypoint] Starting initial sync at $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
python3 /app/sync.py || echo "[entrypoint] sync failed on first run"
# ─── Background sync loop ────────────────────────────────────────────────────
(
while true; do
sleep "$SYNC_INTERVAL"
echo "[entrypoint] Running sync at $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
python3 /app/sync.py || echo "[entrypoint] sync failed"
done
) &
# ─── Background dispatch loop ────────────────────────────────────────────────
(
while true; do
sleep "$DISPATCH_INTERVAL"
echo "[entrypoint] Running dispatch at $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
python3 /app/dispatch.py || echo "[entrypoint] dispatch failed"
done
) &
# ─── Wait on both loops (keeps container alive) ───────────────────────────────
wait