#!/usr/bin/env bash # kb-mail-sync-run.sh — thin launcher for kb-mail-sync.service (faza mailowa Krok 7). # # All sequencing and exit-code logic lives in the Python job (mail_imap_sync/sync.py); this # script only computes a date-stamped log path and redirects, per the repo convention that a # job must never log only to a terminal or the journal — the lesson from the 2026-07 backfill # that lost 4999 rows of diagnostics to a closed tmux. # # Installed at /opt/homelab/kb/kb-mail-sync-run.sh (copied from the repo at install time), # invoked by kb-mail-sync.service. `exec` preserves the job's exit code as this script's own, # so systemd — and `kb_mail_sync_last_exit_code` — see the real result. set -euo pipefail LOG_DIR="/opt/homelab/logs/kb-mail-sync" mkdir -p "$LOG_DIR" LOG_FILE="${LOG_DIR}/run-$(date +%Y%m%d).log" exec /opt/homelab/kb/venv/bin/mail-imap-sync --apply >> "$LOG_FILE" 2>&1