season_info.py - Add ASTRO_YEAR: year of the Winter solstice that started the current cycle (Spring/Summer/Autumn 2026 → 2025; Winter Dec-2026 → 2026) 4-seasons.sh - Daily clip output path now includes ASTRO_YEAR: movies/$name/$ASTRO_YEAR/$SEASON/Mvt$N/ montage-mvt.sh (full rewrite) - Attribution is now a drawtext overlay (top 6 s of the video, fade in/out) instead of an appended black card — no frame-size matching needed, and year-end join requires no special handling - Output path mirrors the new year-based folder structure - Sends notification via notify.sh when done - Automatically triggers year-end-join.sh after Autumn Mvt 3 year-end-join.sh (new) - Concatenates all 12 movement montages for a given ASTRO_YEAR - Output: movies/$name/$ASTRO_YEAR/$name-$ASTRO_YEAR.mp4 - Sends notification when done notify.sh + notify_config.txt (new) - Generic best-effort notification helper: ntfy, email, Mattermost text post - All methods disabled by default; user fills in notify_config.txt sky-cam.crontab + systemd/ (new) - Crontab file: sunrise at 09:00, 4-seasons at 01:00, fullday at 02:00 - systemd .service + .timer units for all three daily jobs - montage/year-end triggered internally, not by cron https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
75 lines
3.2 KiB
Bash
Executable File
75 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# notify.sh — send a notification via ntfy, email, and/or Mattermost.
|
|
#
|
|
# Usage: notify.sh "Title" "Body message"
|
|
#
|
|
# Reads notify_config.txt from the same directory as this script.
|
|
# All methods are independently enabled/disabled in the config.
|
|
# Exits 0 even if all methods fail (notifications are best-effort).
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
|
|
CONFIG="$SCRIPT_DIR/notify_config.txt"
|
|
|
|
TITLE="${1:-Sky-Cam notification}"
|
|
BODY="${2:-}"
|
|
|
|
# ── Load config ───────────────────────────────────────────────────────────────
|
|
if [ ! -f "$CONFIG" ]; then
|
|
echo "notify.sh: config not found at $CONFIG — skipping notifications" >&2
|
|
exit 0
|
|
fi
|
|
|
|
# Source only the known keys; ignore comments and blank lines.
|
|
eval "$(grep -E '^[A-Z_]+=.*' "$CONFIG" | grep -v '^#')"
|
|
|
|
NTFY_ENABLED="${NTFY_ENABLED:-false}"
|
|
NTFY_URL="${NTFY_URL:-}"
|
|
|
|
EMAIL_ENABLED="${EMAIL_ENABLED:-false}"
|
|
EMAIL_TO="${EMAIL_TO:-}"
|
|
EMAIL_FROM="${EMAIL_FROM:-skycam@localhost}"
|
|
|
|
MM_NOTIFY_ENABLED="${MM_NOTIFY_ENABLED:-false}"
|
|
MM_NOTIFY_CHANNEL_ID="${MM_NOTIFY_CHANNEL_ID:-}"
|
|
|
|
# ── ntfy ─────────────────────────────────────────────────────────────────────
|
|
if [ "$NTFY_ENABLED" = "true" ] && [ -n "$NTFY_URL" ]; then
|
|
curl -s \
|
|
-H "Title: $TITLE" \
|
|
-d "$BODY" \
|
|
"$NTFY_URL" > /dev/null \
|
|
&& echo "notify: ntfy sent" \
|
|
|| echo "notify: ntfy failed" >&2
|
|
fi
|
|
|
|
# ── Email ─────────────────────────────────────────────────────────────────────
|
|
if [ "$EMAIL_ENABLED" = "true" ] && [ -n "$EMAIL_TO" ]; then
|
|
echo "$BODY" | mail -s "$TITLE" -r "$EMAIL_FROM" "$EMAIL_TO" \
|
|
&& echo "notify: email sent to $EMAIL_TO" \
|
|
|| echo "notify: email failed" >&2
|
|
fi
|
|
|
|
# ── Mattermost text post ──────────────────────────────────────────────────────
|
|
# Uses the same mattermost_config.txt as sunrise2mm.py but posts to
|
|
# MM_NOTIFY_CHANNEL_ID (can be the same channel or a private admin channel).
|
|
if [ "$MM_NOTIFY_ENABLED" = "true" ] && [ -n "$MM_NOTIFY_CHANNEL_ID" ]; then
|
|
MM_CONFIG="/home/motion/drives/local-2tb/sunrise-scripts/mattermost_config.txt"
|
|
[ ! -f "$MM_CONFIG" ] && MM_CONFIG="$SCRIPT_DIR/mattermost_config.txt"
|
|
if [ -f "$MM_CONFIG" ]; then
|
|
eval "$(grep -E '^(mattermost_url|access_token)=' "$MM_CONFIG")"
|
|
curl -s \
|
|
-H "Authorization: Bearer $access_token" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"channel_id\":\"$MM_NOTIFY_CHANNEL_ID\",\"message\":\"**$TITLE**\n$BODY\"}" \
|
|
"${mattermost_url}/api/v4/posts" > /dev/null \
|
|
&& echo "notify: mattermost sent" \
|
|
|| echo "notify: mattermost failed" >&2
|
|
else
|
|
echo "notify: mattermost_config.txt not found — skipping MM notify" >&2
|
|
fi
|
|
fi
|
|
|
|
exit 0
|