montage-mvt.sh, year-end-join.sh: CAM_NAME fallback referenced undefined \$CAM_NAME — crashes under set -euo pipefail on manual runs without args. Fixed to fall back to \$SUNRISE_CAM (same fix applied earlier to other scripts). notify.sh: Mattermost notification guard only checked MM_NOTIFY_CHANNEL_ID, not mattermost_url or access_token. If those are unset, curl would send a malformed request silently. Added guards for all three required values. install.sh: seasons/fullday service units had literal \n in After=/Wants= lines because bash does not interpret \n in heredoc variable expansions. Changed to \$'...' syntax so actual newlines are written, making valid systemd unit files. Also: audio capture timer now uses \$SCHEDULE_SUNRISE instead of hardcoded 03:00, keeping it in sync if the user changes the schedule. sunrise-audio-capture.sh: record_start_sec could theoretically go negative (sunrise very early + large SUNRISE_TARGET_SECS). Added floor-at-zero guard. daily_sunrise_video.sh: added comment explaining why audio_offset is always 0. README.md: fix CAM_RTSP_sunrise example to CAM_RTSP_east. https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
66 lines
2.7 KiB
Bash
Executable File
66 lines
2.7 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/sky-cam.conf"
|
|
|
|
TITLE="${1:-Sky-Cam notification}"
|
|
BODY="${2:-}"
|
|
|
|
# ── Load config ───────────────────────────────────────────────────────────────
|
|
if [ ! -f "$CONFIG" ]; then
|
|
echo "notify.sh: sky-cam.conf not found — skipping notifications" >&2
|
|
exit 0
|
|
fi
|
|
|
|
source "$CONFIG"
|
|
|
|
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 ──────────────────────────────────────────────────────
|
|
# mattermost_url and access_token come from sky-cam.conf (sourced above).
|
|
if [ "$MM_NOTIFY_ENABLED" = "true" ] && [ -n "$MM_NOTIFY_CHANNEL_ID" ] && [ -n "${mattermost_url:-}" ] && [ -n "${access_token:-}" ]; then
|
|
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
|
|
fi
|
|
|
|
exit 0
|