sky-cam: retire motionEye via direct RTSP capture, drop Frigate detour

capture.sh already replaces motionEye/any NVR itself - it just needs
each camera's RTSP URL. services/sky-cam.sh never actually prompted for
CAM_RTSP_<cam>, so capture/audio never had anything to connect to.

- Prompt per camera for its RTSP URL -> CAM_RTSP_<cam> in .env
- Prompt for sunrise mic / optional ambient audio library
- Fix Mattermost integration: sunrise2mm.py reads mattermost_url/
  access_token/channel_id (bot-token REST upload), not the
  MM_WEBHOOK_URL/MM_CHANNEL incoming-webhook scheme the installer used
  to write - uploads never worked before this
- Add optional ntfy push notifications
- Auto-generate SCHEDULE_SEASONS_<cam> (staggered 30 min apart) for
  every configured camera, not just the stock east/north/south, so
  install.sh wires up every applicable systemd timer for any camera set

Removes services/sky-cam-frigate.sh entirely - routing sky-cam's frames
through Frigate (via export API or restream) turned out to be solving a
problem that doesn't exist; sky-cam's own capture.sh talking directly to
each camera is simpler and has no quality/resolution tradeoffs. Frigate
continues to run fully independently for NVR/detection.
This commit is contained in:
Claude
2026-07-02 05:26:24 +00:00
parent 3c3183bbda
commit dc162b8f8d
4 changed files with 145 additions and 340 deletions
+1 -2
View File
@@ -69,7 +69,7 @@ Update them any time with `sudo ./setup.sh configure`.
| `homelab` | `caddy`, `crowdsec`, `authelia`, `homeassistant`, `asterisk`, `sunshine` |
| `utilities` | `actualbudget`, `ai-gpu`, `ai-stack`, `archivebox`, `changedetection`, `ddclient`, `filebrowser`, `fmd`, `gatus`, `homebox`, `iopaint`, `joplin`, `koha`, `magicmirror`, `mail-archiver`, `mattermost`, `mealie`, `meshcentral`, `n8n`, `nextcloud`, `ntfy`, `onlyoffice`, `paintplus`, `portainer`, `rustdesk`, `stirling-pdf`, `syncthing`, `traccar`, `unifi`, `uptimekuma`, `vaultwarden`, `watchyourlan`, `watchtower`, `wg-easy` |
| `media` | `arm`, `audiobookshelf`, `calibre-web`, `emby`, `immich`, `jellyfin`, `lyrion` |
| `cameras` | `frigate`, `frigate-audio`, `frigate-notify`, `sky-cam`, `sky-cam-frigate` |
| `cameras` | `frigate`, `frigate-audio`, `frigate-notify`, `sky-cam` |
| `gaming` | `drum-rhythm-game`, `js99er`, `kyber-launcher`, `kyber-server`, `minecraft`, `wolf`, `wolf-pair` |
| `extras` | `kdeconnect`, `silent-send`, `sync-cc` |
| `backup` | `backup` — complete recovery: entire `~/docker/<service>/` for every service via Kopia (Minecraft: flush+snap, no downtime; others: stop/snap/start for DB consistency); `borg-backup` — same coverage via Borg (chunk dedup, SSH remote repos, Borgmatic/Vorta compatible); `gaming-backup` — frequent game-save snapshots (Minecraft world data, emulator saves, Steam — no downtime, run hourly) |
@@ -142,7 +142,6 @@ cameras
frigate-audio
frigate-notify
sky-cam
sky-cam-frigate
gaming
drum-rhythm-game
-305
View File
@@ -1,305 +0,0 @@
#!/bin/bash
# services/sky-cam-frigate.sh — Automated sky / timelapse camera scripts
# (sky-cam), configured to source frames from Frigate instead of a camera's
# RTSP stream directly.
# Part of the modular post-install system (sourced by setup.sh).
#
# Can also be run standalone on any machine:
# sudo bash sky-cam-frigate.sh
# (Docker must already be installed when run standalone; Frigate should
# already be configured with the cameras you want — see services/frigate.sh.)
#
# NON-DOCKER module — this is the exact same upstream sky-cam project as
# services/sky-cam.sh (same clone, same scripts, same systemd timers). The
# only difference is what CAM_RTSP_<cam> points to in .env:
#
# sky-cam.sh CAM_RTSP_<cam> = the camera's own RTSP URL directly
# sky-cam-frigate.sh CAM_RTSP_<cam> = Frigate's go2rtc restream for that
# camera (rtsp://<frigate-host>:8554/<cam>)
#
# Why this is the only change needed: sky-cam's capture.sh is itself a
# from-scratch RTSP frame-grabber that "replaces MotionEye or any NVR" (its
# own header comment) — it pulls one JPEG frame every CAPTURE_INTERVAL
# seconds from whatever CAM_RTSP_<cam> points to and writes it to
# BASE_DIR/<cam>/YYYY-MM-DD/HH-MM-SS.jpg. Every other script in the pipeline
# (4-seasons.sh, montage-mvt.sh, year-end-join.sh, moon-track.sh,
# moon-phase-monthly.sh, daily_sunrise_video.sh) only ever reads JPEGs/audio
# already sitting in BASE_DIR — none of them know or care whether the camera
# was reached directly or through Frigate's restream. Pointing capture.sh at
# Frigate's go2rtc endpoint instead of the camera means Frigate stays the
# single RTSP client against the camera (recording + detection), and sky-cam
# becomes a second, cheap consumer of Frigate's already-open stream — no
# upstream sky-cam script edits required.
#
# Source: https://github.com/outis1one/sky-cam (cloned via bootstrap.sh)
# Installs systemd user timers via sky-cam's own install.sh.
# ── Standalone bootstrap ──────────────────────────────────────────────────────
# Detected when the script is executed directly rather than sourced by setup.sh.
# Sets up helpers and globals, then defers execution until after the function
# definition at the bottom of this file.
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
[[ "$(id -u)" == "0" ]] || { echo "Run with sudo: sudo bash $0"; exit 1; }
_SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_COMMON="$_SELF_DIR/../lib/common.sh"
if [[ -f "$_COMMON" ]]; then
# Full repo present — use the real helpers (picks up ~/docker/.config too)
# shellcheck source=../lib/common.sh
source "$_COMMON"
else
# One-off copy — inline minimal stubs so the script works without the repo
log_info() { echo -e "\033[0;34m[INFO]\033[0m $*"; }
log_success() { echo -e "\033[0;32m[OK]\033[0m $*"; }
log_warning() { echo -e "\033[1;33m[WARN]\033[0m $*"; }
log_error() { echo -e "\033[0;31m[ERROR]\033[0m $*" >&2; }
run_cmd() {
"$@"
}
pip_user_install() {
pip3 --user --break-system-packages "$@" 2>/dev/null \
|| pip3 --user "$@"
}
# Match common.sh's eval-based pattern so local vars in install_* are set correctly
prompt_text() {
local _q="$1" _def="$2" _var="$3" _r
[[ "${UNATTENDED:-false}" == "true" ]] && { eval "$_var='$_def'"; return; }
read -r -p " $_q " _r
eval "$_var='${_r:-$_def}'"
}
prompt_yn() {
local _q="$1" _def="$2" _var="$3" _r
[[ "${UNATTENDED:-false}" == "true" ]] && { eval "$_var='$_def'"; return; }
read -r -p " $_q " _r
eval "$_var='${_r:-$_def}'"
}
fi
# Globals — ACTUAL_USER/ACTUAL_HOME must come before DOCKER_DIR
# ($HOME under sudo is /root, not the real user's home)
ACTUAL_USER="${ACTUAL_USER:-${SUDO_USER:-$USER}}"
ACTUAL_HOME="$(getent passwd "$ACTUAL_USER" 2>/dev/null | cut -d: -f6 || echo "${HOME:-/root}")"
DOCKER_DIR="${DOCKER_DIR:-$ACTUAL_HOME/docker}"
DRY_RUN="${DRY_RUN:-false}"
UNATTENDED="${UNATTENDED:-false}"
SITE_TZ="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
SITE_DOMAIN="${SITE_DOMAIN:-example.com}"
SITE_CADDY_NET="${SITE_CADDY_NET:-caddy_net}"
CADDY_REMOTE_HOST="${CADDY_REMOTE_HOST:-}"
register_service() { :; } # no-op — no wizard to register into
_RUN_STANDALONE=1
fi
# ─────────────────────────────────────────────────────────────────────────────
register_service sky-cam-frigate cameras "Automated sky / timelapse camera scripts sourced from Frigate's restream instead of RTSP directly (sky-cam + Frigate)"
# Prints space-separated camera names parsed from an existing Frigate
# config.yml's top-level `cameras:` block. Best-effort only — same 2-space
# indent assumption services/frigate.sh's own parser relies on.
_skycam_frigate_detect_cameras() {
local cfg="$1"
[ -f "$cfg" ] || return 0
awk '
/^cameras:/ { in_cams=1; next }
in_cams && /^[a-zA-Z]/ { in_cams=0 }
in_cams && /^ [a-z0-9_]+:[[:space:]]*$/ { gsub(/[: ]/, ""); print }
' "$cfg" | tr '\n' ' '
}
install_sky-cam-frigate() {
local SKYCAM_DIR="$ACTUAL_HOME/sky-cam"
if [ "$DRY_RUN" = true ]; then
echo "[DRY-RUN] sky-cam-frigate would:"
echo " - Install: ffmpeg bc fonts-dejavu curl python3-pip"
echo " - pip install: suntime pytz requests skyfield Pillow numpy scipy"
echo " - Clone sky-cam to $SKYCAM_DIR via bootstrap.sh (same repo as sky-cam.sh)"
echo " - Detect cameras from an existing Frigate config.yml, if present"
echo " - Write CAM_RTSP_<cam>=rtsp://<frigate-host>:8554/<cam> into .env"
echo " (Frigate's go2rtc restream, instead of the camera's own RTSP URL)"
echo " - Edit sky-cam.conf with your location and camera names"
echo " - Copy .env.example → .env and set Mattermost credentials"
echo " - Run ./install.sh to register systemd user timers"
return 0
fi
echo ""
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ sky-cam + Frigate — Sky & Timelapse Camera System ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo ""
log_info "This is the same sky-cam project as services/sky-cam.sh — the only"
log_info "difference is CAM_RTSP_<cam> points at Frigate's restream instead of"
log_info "the camera directly, so Frigate stays the single RTSP client per camera."
echo ""
# ── System packages ──────────────────────────────────────────────────────
log_info "Installing system dependencies..."
run_cmd apt-get update -qq
run_cmd apt-get install -y --no-install-recommends \
ffmpeg bc fonts-dejavu curl python3-pip git
log_success "System packages installed"
# ── Python packages ──────────────────────────────────────────────────────
log_info "Installing Python packages..."
pip_user_install suntime pytz requests skyfield Pillow numpy scipy \
|| log_warning "Some pip packages may have failed — check output above"
log_success "Python packages installed"
# ── Clone sky-cam ────────────────────────────────────────────────────────
if [ -d "$SKYCAM_DIR/.git" ]; then
log_info "sky-cam already cloned at $SKYCAM_DIR — pulling latest..."
sudo -u "$ACTUAL_USER" git -C "$SKYCAM_DIR" pull --ff-only \
|| log_warning "git pull failed — continuing with existing version"
else
log_info "Cloning sky-cam from GitHub..."
sudo -u "$ACTUAL_USER" bash -c "
curl -fsSL https://raw.githubusercontent.com/outis1one/sky-cam/main/bootstrap.sh \
| bash -s -- '$SKYCAM_DIR'
" || { log_error "Failed to clone sky-cam — check internet connection"; return 1; }
log_success "sky-cam cloned to $SKYCAM_DIR"
fi
# ── Frigate detection ────────────────────────────────────────────────────
local FRIGATE_CFG="$DOCKER_DIR/frigate/config/config.yml"
local DEFAULT_CAMS="east"
local FRIGATE_HOST="127.0.0.1"
if [ -f "$FRIGATE_CFG" ]; then
log_success "Found existing Frigate config at $DOCKER_DIR/frigate"
local _detected
_detected="$(_skycam_frigate_detect_cameras "$FRIGATE_CFG")"
[ -n "$_detected" ] && DEFAULT_CAMS="$_detected"
else
log_warning "No Frigate config found at $DOCKER_DIR/frigate — run services/frigate.sh first"
log_warning "if Frigate isn't configured yet. Camera names below must match Frigate's"
log_warning "config.yml camera keys once it is, or capture.sh will connect to nothing."
fi
echo ""
log_info "Location and camera configuration"
echo " sky-cam needs your GPS coordinates and timezone to calculate"
echo " sunrise times accurately. Use decimal degrees (e.g. 40.7128, -74.0060)."
echo ""
local LATITUDE="" LONGITUDE="" TIMEZONE="" CAMERAS_LIST="" SUNRISE_CAM=""
prompt_text " Latitude (decimal degrees) [0.0000]:" "0.0000" LATITUDE
prompt_text " Longitude (decimal degrees) [0.0000]:" "0.0000" LONGITUDE
prompt_text " Timezone [${SITE_TZ:-America/New_York}]:" "${SITE_TZ:-America/New_York}" TIMEZONE
echo ""
echo " Camera names must match the camera keys configured in Frigate's"
echo " config.yml (services/frigate.sh)."
echo ""
prompt_text " Camera names (space-separated) [$DEFAULT_CAMS]:" "$DEFAULT_CAMS" CAMERAS_LIST
local _default_sunrise; _default_sunrise="$(awk '{print $1}' <<< "$CAMERAS_LIST")"
prompt_text " Sunrise camera (faces east) [$_default_sunrise]:" "$_default_sunrise" SUNRISE_CAM
echo ""
log_info "Frigate connection"
echo " sky-cam's capture.sh runs directly on this host and connects to"
echo " Frigate's go2rtc RTSP restream (port 8554) instead of the camera."
echo ""
prompt_text " Frigate host [$FRIGATE_HOST]:" "$FRIGATE_HOST" FRIGATE_HOST
# Prompt for Mattermost credentials
echo ""
log_info "Mattermost webhook (for automated uploads)"
echo " sky-cam posts sunrise clips and moon photos to a Mattermost channel."
echo " Create an incoming webhook in Mattermost: Settings → Integrations → Webhooks"
echo " (Leave blank to skip — add to $SKYCAM_DIR/.env later)"
echo ""
local MM_WEBHOOK="" MM_CHANNEL=""
if [ "$UNATTENDED" != true ]; then
read -p " Mattermost webhook URL [Enter to skip]: " MM_WEBHOOK
if [ -n "$MM_WEBHOOK" ]; then
prompt_text " Mattermost channel name [sky-cam]:" "sky-cam" MM_CHANNEL
fi
fi
# ── Write .env ───────────────────────────────────────────────────────────
log_info "Writing sky-cam.conf overrides to $SKYCAM_DIR/.env..."
{
echo "# sky-cam site configuration — generated by ubuntu-post-install"
echo "# Edit sky-cam.conf for full settings."
echo ""
echo "LATITUDE=${LATITUDE:-0.0000}"
echo "LONGITUDE=${LONGITUDE:-0.0000}"
echo "TIMEZONE=${TIMEZONE:-America/New_York}"
echo ""
echo "# Frigate's go2rtc restream stands in for each camera's direct RTSP"
echo "# URL — Frigate stays the only RTSP client against the camera itself."
for _cam in $CAMERAS_LIST; do
local _var; _var="CAM_RTSP_${_cam}"
echo "${_var}=rtsp://${FRIGATE_HOST}:8554/${_cam}"
done
echo ""
if [ -n "$MM_WEBHOOK" ]; then
echo "MM_WEBHOOK_URL=${MM_WEBHOOK}"
echo "MM_CHANNEL=${MM_CHANNEL:-sky-cam}"
else
echo "# MM_WEBHOOK_URL=https://mattermost.yourdomain.com/hooks/your-webhook-id"
echo "# MM_CHANNEL=sky-cam"
fi
} > "$SKYCAM_DIR/.env"
chmod 600 "$SKYCAM_DIR/.env"
# ── Patch sky-cam.conf with cameras and basic settings ───────────────────
local CONF="$SKYCAM_DIR/sky-cam.conf"
if [ -f "$CONF" ]; then
log_info "Patching sky-cam.conf with location and camera names..."
local CAM_ARRAY="(${CAMERAS_LIST})"
sed -i "s|^CAMERAS=.*|CAMERAS=${CAM_ARRAY}|" "$CONF"
sed -i "s|^SUNRISE_CAM=.*|SUNRISE_CAM=${SUNRISE_CAM}|" "$CONF"
log_success "sky-cam.conf updated"
else
log_warning "sky-cam.conf not found — check $SKYCAM_DIR"
fi
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$SKYCAM_DIR" 2>/dev/null || true
# ── Install systemd timers ────────────────────────────────────────────────
if [ -f "$SKYCAM_DIR/install.sh" ]; then
log_info "Installing systemd user timers via install.sh..."
( cd "$SKYCAM_DIR" && sudo -u "$ACTUAL_USER" bash install.sh ) \
&& log_success "Systemd timers installed" \
|| log_warning "install.sh failed — run manually: cd $SKYCAM_DIR && ./install.sh"
else
log_warning "install.sh not found in $SKYCAM_DIR — run it manually after review"
fi
# ── Summary ───────────────────────────────────────────────────────────────
echo ""
echo "═══════════════════════════════════════════════════════"
echo " sky-cam-frigate installed"
echo "═══════════════════════════════════════════════════════"
echo ""
echo " Location: $SKYCAM_DIR"
echo " Frigate: rtsp://${FRIGATE_HOST}:8554/<camera>"
echo " Cameras: $CAMERAS_LIST"
echo " Timezone: ${TIMEZONE:-America/New_York}"
echo ""
echo " Next steps:"
echo " 1. Review $SKYCAM_DIR/sky-cam.conf"
echo " — schedules, encoding settings, moon-job thresholds"
echo " 2. Put your Vivaldi Four Seasons audio files in:"
echo " $SKYCAM_DIR/music/"
echo " 3. Confirm frames are landing:"
echo " systemctl --user status sky-cam-capture-${SUNRISE_CAM}.service"
echo " ls $SKYCAM_DIR/data/${SUNRISE_CAM}/\$(date +%Y-%m-%d)/"
echo " 4. Verify all timers:"
echo " systemctl --user list-timers 'sky-cam-*'"
echo ""
echo " Logs:"
echo " journalctl --user -u sky-cam-capture-${SUNRISE_CAM}.service -f"
echo " journalctl --user -u sky-cam-sunrise.service -f"
echo ""
}
# Run immediately when executed directly (deferred until after function definition)
[[ "${_RUN_STANDALONE:-0}" == 1 ]] && install_sky-cam-frigate
+144 -32
View File
@@ -7,12 +7,20 @@
# (Docker must already be installed when run standalone)
#
# NON-DOCKER module. sky-cam produces:
# • Daily sunrise clip — speed-adjusted video, uploaded to Mattermost
# • Daily sunrise clip — speed-adjusted video (+ optional audio), uploaded to Mattermost
# • Four Seasons timelapse — daily clips sized to Vivaldi movements' music
# • Full-day timelapse — fixed-fps timelapse of every captured image
# • Moon-track timelapse — moon tracked & cropped each visible night
# • Monthly moon-phase close-ups — NASA Dial-a-Moon images posted to MM
#
# No motionEye or any NVR required — sky-cam's own capture.sh connects
# directly to each camera's RTSP stream and grabs frames itself
# (CAM_RTSP_<cam> in .env is the only thing capture.sh and the optional
# sunrise-audio/ambient-audio recorders need). This installer prompts for
# that per camera, so install.sh can generate every applicable systemd
# timer/service (capture, watchdog, sunrise, audio, ambient, moon jobs,
# per-camera seasons clips) in one pass.
#
# Source: https://github.com/outis1one/sky-cam (cloned via bootstrap.sh)
# Installs systemd user timers via sky-cam's install.sh.
@@ -89,9 +97,12 @@ install_sky-cam() {
echo " - Install: ffmpeg bc fonts-dejavu curl python3-pip"
echo " - pip install: suntime pytz requests skyfield Pillow numpy scipy"
echo " - Clone sky-cam to $SKYCAM_DIR via bootstrap.sh"
echo " - Edit sky-cam.conf with your location and camera names"
echo " - Copy .env.example → .env and set Mattermost credentials"
echo " - Run ./install.sh to register systemd user timers"
echo " - Prompt for each camera's RTSP URL -> CAM_RTSP_<cam> in .env"
echo " (capture.sh connects directly - no motionEye or other NVR needed)"
echo " - Prompt for sunrise audio / optional ambient audio library"
echo " - Prompt for Mattermost (mattermost_url/access_token/channel_id) + ntfy"
echo " - Patch sky-cam.conf: cameras, audio toggles, per-camera seasons schedule"
echo " - Run ./install.sh to register every applicable systemd timer/service"
return 0
fi
@@ -142,31 +153,84 @@ install_sky-cam() {
echo ""
echo " Camera names are short identifiers, e.g.: east north south west"
echo " These names must match the directories where your camera images are saved."
echo " capture.sh creates BASE_DIR/<camera-name>/ itself — no pre-existing folders needed."
echo ""
prompt_text " Camera names (space-separated) [east]:" "east" CAMERAS_LIST
prompt_text " Sunrise camera (faces east) [east]:" "east" SUNRISE_CAM
echo ""
echo " BASE_DIR is where your camera images live."
echo " Each camera should have a sub-folder: BASE_DIR/<camera-name>/"
echo " BASE_DIR is where captured images/videos are written. Leave default unless"
echo " you want them on a separate drive or network mount."
local DEFAULT_BASE="$ACTUAL_HOME/sky-cam/data"
prompt_text " Image base directory [$DEFAULT_BASE]:" "$DEFAULT_BASE" BASE_DIR
[ -z "$BASE_DIR" ] && BASE_DIR="$DEFAULT_BASE"
# Prompt for Mattermost credentials
# ── Camera RTSP connections ───────────────────────────────────────────────
# capture.sh IS the motionEye replacement — it needs each camera's RTSP URL
# directly. This is the one variable every downstream script depends on
# (capture.sh for frames, sunrise-audio-capture.sh/ambient-record.sh for audio).
echo ""
log_info "Mattermost webhook (for automated uploads)"
echo " sky-cam posts sunrise clips and moon photos to a Mattermost channel."
echo " Create an incoming webhook in Mattermost: Settings → Integrations → Webhooks"
echo " (Leave blank to skip — add to $SKYCAM_DIR/.env later)"
log_info "Camera RTSP connections"
echo " Find each camera's RTSP URL in its web UI (usually Network → Video → RTSP)"
echo " or its manual. Format: rtsp://username:password@camera-ip:554/stream-path"
echo " If the password has special characters, sky-cam's url-encode-password.py"
echo " can encode it for you (run after cloning, before pasting the URL below)."
echo " Leave blank to skip a camera for now — add CAM_RTSP_<cam> to .env later."
echo ""
local MM_WEBHOOK="" MM_CHANNEL=""
if [ "$UNATTENDED" != true ]; then
read -p " Mattermost webhook URL [Enter to skip]: " MM_WEBHOOK
if [ -n "$MM_WEBHOOK" ]; then
prompt_text " Mattermost channel name [sky-cam]:" "sky-cam" MM_CHANNEL
local CAM_RTSP_ENV="" _cam _rtsp
for _cam in $CAMERAS_LIST; do
_rtsp=""
prompt_text " ${_cam} RTSP URL:" "" _rtsp
if [ -n "$_rtsp" ]; then
CAM_RTSP_ENV="${CAM_RTSP_ENV}CAM_RTSP_${_cam}=${_rtsp}
"
else
log_warning "No RTSP URL for ${_cam} — capture won't start until CAM_RTSP_${_cam} is set in .env"
fi
done
# ── Sunrise audio ─────────────────────────────────────────────────────────
echo ""
echo " If the sunrise camera has a mic, sky-cam records natural audio centred"
echo " on the actual sunrise moment and mixes it into the video."
local AUDIO_MIC=""
prompt_yn " Does ${SUNRISE_CAM} have a working microphone? (y/n):" "y" AUDIO_MIC
# ── Ambient audio library (optional fallback) ─────────────────────────────
echo ""
echo " Optional: continuously record an ambient sound library (birds/rain/wind)"
echo " as a fallback for the sunrise video on days with no dedicated recording."
local AMBIENT="" AMBIENT_CAMS_LIST=""
prompt_yn " Enable the ambient audio library? (y/n):" "n" AMBIENT
if [[ "$AMBIENT" =~ ^[Yy]$ ]]; then
prompt_text " Camera(s) to record ambient audio from (space-separated) [${SUNRISE_CAM}]:" \
"$SUNRISE_CAM" AMBIENT_CAMS_LIST
fi
# ── Mattermost (file uploads) ─────────────────────────────────────────────
# sunrise2mm.py reads mattermost_url / access_token / channel_id (lowercase,
# bot/PAT REST-API upload) — NOT an incoming webhook. Incoming webhooks can't
# attach binary files, so a webhook URL alone would silently never upload.
echo ""
log_info "Mattermost (uploads sunrise clips + moon photos)"
echo " Needs a token that can post in the target channel — Mattermost System"
echo " Console → Integrations → Bot Accounts, or a user's own Personal Access"
echo " Token (Account Settings → Security → Personal Access Tokens)."
echo " (Leave the URL blank to skip — add to $SKYCAM_DIR/.env later)"
echo ""
local MM_URL="" MM_TOKEN="" MM_CHANNEL_ID=""
read -p " Mattermost URL (e.g. https://mattermost.example.com) [Enter to skip]: " MM_URL
if [ -n "$MM_URL" ]; then
prompt_text " Access token:" "" MM_TOKEN
prompt_text " Channel ID (for sunrise/moon uploads):" "" MM_CHANNEL_ID
fi
# ── ntfy push notifications (optional, separate from Mattermost) ─────────
echo ""
local NTFY="" NTFY_TOPIC_URL=""
prompt_yn " Enable ntfy.sh push notifications for job status/failures? (y/n):" "n" NTFY
if [[ "$NTFY" =~ ^[Yy]$ ]]; then
prompt_text " ntfy topic URL (e.g. https://ntfy.sh/your-topic):" "" NTFY_TOPIC_URL
fi
# ── Write .env ───────────────────────────────────────────────────────────
@@ -179,24 +243,65 @@ install_sky-cam() {
echo "LONGITUDE=${LONGITUDE:-0.0000}"
echo "TIMEZONE=${TIMEZONE:-America/New_York}"
echo "BASE_DIR=${BASE_DIR}"
if [ -n "$MM_WEBHOOK" ]; then
echo "MM_WEBHOOK_URL=${MM_WEBHOOK}"
echo "MM_CHANNEL=${MM_CHANNEL:-sky-cam}"
echo ""
echo "# Per-camera RTSP — capture.sh connects directly (replaces motionEye)."
printf '%s' "$CAM_RTSP_ENV"
echo ""
if [ -n "$MM_URL" ]; then
echo "mattermost_url=${MM_URL}"
echo "access_token=${MM_TOKEN}"
echo "channel_id=${MM_CHANNEL_ID}"
else
echo "# MM_WEBHOOK_URL=https://mattermost.yourdomain.com/hooks/your-webhook-id"
echo "# MM_CHANNEL=sky-cam"
echo "# mattermost_url=https://mattermost.yourdomain.com"
echo "# access_token=your-bot-or-personal-access-token"
echo "# channel_id=your-channel-id"
fi
if [ -n "$NTFY_TOPIC_URL" ]; then
echo "NTFY_URL=${NTFY_TOPIC_URL}"
fi
} > "$SKYCAM_DIR/.env"
chmod 600 "$SKYCAM_DIR/.env"
# ── Patch sky-cam.conf with cameras and basic settings ───────────────────
# ── Patch sky-cam.conf ────────────────────────────────────────────────────
local CONF="$SKYCAM_DIR/sky-cam.conf"
if [ -f "$CONF" ]; then
log_info "Patching sky-cam.conf with location and camera names..."
# Build CAMERAS=(...) line
log_info "Patching sky-cam.conf with location, cameras, audio, and schedules..."
local CAM_ARRAY="(${CAMERAS_LIST})"
sed -i "s|^CAMERAS=.*|CAMERAS=${CAM_ARRAY}|" "$CONF"
sed -i "s|^SUNRISE_CAM=.*|SUNRISE_CAM=${SUNRISE_CAM:-east}|" "$CONF"
if [[ "$AUDIO_MIC" =~ ^[Yy]$ ]]; then
sed -i "s|^AUDIO_ENABLED=.*|AUDIO_ENABLED=true|" "$CONF"
else
sed -i "s|^AUDIO_ENABLED=.*|AUDIO_ENABLED=false|" "$CONF"
fi
if [[ "$AMBIENT" =~ ^[Yy]$ ]]; then
sed -i "s|^AMBIENT_ENABLED=.*|AMBIENT_ENABLED=true|" "$CONF"
sed -i "s|^AMBIENT_CAMS=.*|AMBIENT_CAMS=(${AMBIENT_CAMS_LIST})|" "$CONF"
fi
if [ -n "$NTFY_TOPIC_URL" ]; then
sed -i "s|^NTFY_ENABLED=.*|NTFY_ENABLED=true|" "$CONF"
fi
# Every configured camera needs its own seasons schedule — stock
# sky-cam.conf only ships defaults for east/north/south, staggered
# 30 min apart starting at 01:00 (upstream's own spacing advice).
local _idx=0
for _cam in $CAMERAS_LIST; do
local _total_min=$(( 60 + _idx * 30 ))
local _hh=$(( (_total_min / 60) % 24 ))
local _mm=$(( _total_min % 60 ))
local _sched; _sched="$(printf '%02d:%02d:00' "$_hh" "$_mm")"
if grep -q "^SCHEDULE_SEASONS_${_cam}=" "$CONF"; then
sed -i "s|^SCHEDULE_SEASONS_${_cam}=.*|SCHEDULE_SEASONS_${_cam}=${_sched}|" "$CONF"
else
echo "SCHEDULE_SEASONS_${_cam}=${_sched}" >> "$CONF"
fi
_idx=$((_idx+1))
done
log_success "sky-cam.conf updated"
else
log_warning "sky-cam.conf not found — check $SKYCAM_DIR"
@@ -226,25 +331,32 @@ install_sky-cam() {
echo " sky-cam installed"
echo "═══════════════════════════════════════════════════════"
echo ""
echo " Location: $SKYCAM_DIR"
echo " Data: $BASE_DIR"
echo " Cameras: $CAMERAS_LIST"
echo " Timezone: ${TIMEZONE:-America/New_York}"
echo " Location: $SKYCAM_DIR"
echo " Data: $BASE_DIR"
echo " Cameras: $CAMERAS_LIST"
echo " Timezone: ${TIMEZONE:-America/New_York}"
echo " Audio: $([ "$AUDIO_MIC" = "y" ] || [ "$AUDIO_MIC" = "Y" ] && echo "sunrise mic enabled" || echo "disabled")"
echo " Ambient: $([[ "$AMBIENT" =~ ^[Yy]$ ]] && echo "enabled ($AMBIENT_CAMS_LIST)" || echo "disabled")"
echo " Mattermost: $([ -n "$MM_URL" ] && echo "configured" || echo "not configured")"
echo " ntfy: $([ -n "$NTFY_TOPIC_URL" ] && echo "configured" || echo "not configured")"
echo ""
echo " Next steps:"
echo " 1. Review $SKYCAM_DIR/sky-cam.conf"
echo " — SCRIPT_DIR, MUSIC_DIR, schedules, encoding settings"
echo " — MUSIC_DIR, encoding settings, moon-job thresholds"
echo " 2. Put your Vivaldi Four Seasons audio files in:"
echo " $SKYCAM_DIR/music/"
echo " (filenames and expected MUSIC_DIR path are in sky-cam.conf)"
echo " 3. Verify systemd timers:"
echo " 3. Confirm frames are landing:"
echo " systemctl --user status sky-cam-capture-${SUNRISE_CAM}.service"
echo " ls $BASE_DIR/${SUNRISE_CAM}/\$(date +%Y-%m-%d)/"
echo " 4. Verify all timers:"
echo " systemctl --user list-timers 'sky-cam-*'"
echo " 4. Credentials → $SKYCAM_DIR/.env"
echo ""
echo " To test the sunrise script manually:"
echo " cd $SKYCAM_DIR && ./daily_sunrise_video.sh"
echo ""
echo " Logs:"
echo " journalctl --user -u sky-cam-capture-${SUNRISE_CAM}.service -f"
echo " journalctl --user -u sky-cam-sunrise.service -f"
echo ""
}
-1
View File
@@ -87,7 +87,6 @@ is_installed() {
silent-send) [ -d "$ACTUAL_HOME/silent-send/.git" ] ;;
sync-cc) [ -f "$ACTUAL_HOME/sync-cc/sync_cc.py" ] ;;
sky-cam) [ -d "$ACTUAL_HOME/sky-cam/.git" ] ;;
sky-cam-frigate) [ -d "$ACTUAL_HOME/sky-cam/.git" ] && [ -f "$ACTUAL_HOME/sky-cam/frigate-retime.sh" ] ;;
*) [ -e "$DOCKER_DIR/$1" ] ;;
esac
}