Multi-camera support; schedules in conf; comment out notifications
sky-cam.conf: - CAMERAS array replaces single CAM_NAME; add a name, add its schedules, re-run install.sh — no script editing needed - SCHEDULE_SUNRISE, SCHEDULE_SEASONS_<cam>, SCHEDULE_FULLDAY_<cam> replace hardcoded times in install.sh - Notification options commented out (uncomment to enable) - Lat/lon set to mid-Atlantic (25.0, -38.0) as neutral placeholder install.sh: - Loops over CAMERAS to generate per-camera sky-cam-seasons-<cam> and sky-cam-fullday-<cam> timers with schedules from conf - Sunrise timer remains a single sky-cam-sunrise unit (SUNRISE_CAM only) fullday-video.sh, 4-seasons.sh, montage-mvt.sh, year-end-join.sh: - Each accepts camera name as an argument (systemd passes it via ExecStart) and falls back to conf default when run manually without an arg - Camera name propagates through the full call chain: 4-seasons → montage-mvt → year-end-join https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
+42
-22
@@ -6,7 +6,8 @@
|
||||
# ./install.sh --system # installs to /etc/systemd/system (needs sudo)
|
||||
#
|
||||
# Run this once after editing sky-cam.conf, and again whenever sky-cam.conf
|
||||
# changes (e.g. SCRIPT_DIR moves). No other file needs editing.
|
||||
# changes (e.g. SCRIPT_DIR moves, cameras added, schedules changed).
|
||||
# No other file needs editing.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
@@ -33,7 +34,7 @@ write_service() {
|
||||
local unit="$1" description="$2" script="$3" extra="${4:-}"
|
||||
cat > "$UNIT_DIR/${unit}.service" <<EOF
|
||||
[Unit]
|
||||
Description=Sky-Cam ($CAM_NAME) — $description
|
||||
Description=Sky-Cam — $description
|
||||
${extra}OnFailure=sky-cam-notify-failure@%n.service
|
||||
|
||||
[Service]
|
||||
@@ -50,10 +51,10 @@ write_timer() {
|
||||
local unit="$1" description="$2" calendar="$3"
|
||||
cat > "$UNIT_DIR/${unit}.timer" <<EOF
|
||||
[Unit]
|
||||
Description=Sky-Cam ($CAM_NAME) — $description
|
||||
Description=Sky-Cam — $description
|
||||
|
||||
[Timer]
|
||||
OnCalendar=$calendar
|
||||
OnCalendar=*-*-* $calendar
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
@@ -73,32 +74,51 @@ ExecStart=$SCRIPT_DIR/notify.sh "sky-cam job failed: %i" "systemd unit %i failed
|
||||
EOF
|
||||
echo " wrote sky-cam-notify-failure@.service"
|
||||
|
||||
# ── Three daily jobs ──────────────────────────────────────────────────────────
|
||||
# Sunrise video → Mattermost (run after sunrise window ends)
|
||||
# ── Sunrise video — SUNRISE_CAM only ─────────────────────────────────────────
|
||||
write_service "sky-cam-sunrise" \
|
||||
"daily sunrise video → Mattermost" \
|
||||
"$SUNRISE_CAM: daily sunrise video → Mattermost" \
|
||||
"daily_sunrise_video.sh" \
|
||||
"After=network-online.target\nWants=network-online.target\n"
|
||||
write_timer "sky-cam-sunrise" "daily sunrise video" "*-*-* 09:00:00"
|
||||
write_timer "sky-cam-sunrise" "$SUNRISE_CAM: daily sunrise video" "$SCHEDULE_SUNRISE"
|
||||
|
||||
# Four Seasons daily clip (auto-triggers montage + year-end on last days)
|
||||
write_service "sky-cam-4seasons" \
|
||||
"Four Seasons daily clip" \
|
||||
"4-seasons.sh" \
|
||||
"After=network-online.target\nWants=network-online.target\n"
|
||||
write_timer "sky-cam-4seasons" "Four Seasons daily clip" "*-*-* 01:00:00"
|
||||
timers=(sky-cam-sunrise)
|
||||
|
||||
# Full-day timelapse with 10-day retention
|
||||
write_service "sky-cam-fullday" \
|
||||
"full-day timelapse" \
|
||||
"fullday-video.sh"
|
||||
write_timer "sky-cam-fullday" "full-day timelapse" "*-*-* 02:00:00"
|
||||
# ── Per-camera Four Seasons and full-day jobs ─────────────────────────────────
|
||||
# Reads CAMERAS, SCHEDULE_SEASONS_<cam>, SCHEDULE_FULLDAY_<cam> from sky-cam.conf.
|
||||
# Scripts receive the camera name as $1 so they know which camera to process.
|
||||
for cam in "${CAMERAS[@]}"; do
|
||||
sched_seasons_var="SCHEDULE_SEASONS_${cam}"
|
||||
sched_fullday_var="SCHEDULE_FULLDAY_${cam}"
|
||||
|
||||
if [ -n "${!sched_seasons_var:-}" ]; then
|
||||
write_service "sky-cam-seasons-${cam}" \
|
||||
"${cam}: Four Seasons daily clip" \
|
||||
"4-seasons.sh ${cam}" \
|
||||
"After=network-online.target\nWants=network-online.target\n"
|
||||
write_timer "sky-cam-seasons-${cam}" "${cam}: Four Seasons daily clip" \
|
||||
"${!sched_seasons_var}"
|
||||
timers+=("sky-cam-seasons-${cam}")
|
||||
else
|
||||
echo " WARNING: SCHEDULE_SEASONS_${cam} not set — skipping seasons timer for ${cam}"
|
||||
fi
|
||||
|
||||
if [ -n "${!sched_fullday_var:-}" ]; then
|
||||
write_service "sky-cam-fullday-${cam}" \
|
||||
"${cam}: full-day timelapse" \
|
||||
"fullday-video.sh ${cam}"
|
||||
write_timer "sky-cam-fullday-${cam}" "${cam}: full-day timelapse" \
|
||||
"${!sched_fullday_var}"
|
||||
timers+=("sky-cam-fullday-${cam}")
|
||||
else
|
||||
echo " WARNING: SCHEDULE_FULLDAY_${cam} not set — skipping fullday timer for ${cam}"
|
||||
fi
|
||||
done
|
||||
|
||||
# ── Reload and enable ─────────────────────────────────────────────────────────
|
||||
echo ""
|
||||
$SC daemon-reload
|
||||
|
||||
for timer in sky-cam-sunrise sky-cam-4seasons sky-cam-fullday; do
|
||||
for timer in "${timers[@]}"; do
|
||||
$SC enable --now "${timer}.timer" \
|
||||
&& echo " enabled + started ${timer}.timer" \
|
||||
|| echo " WARNING: could not enable ${timer}.timer"
|
||||
@@ -108,8 +128,8 @@ echo ""
|
||||
echo "Done. Check status with:"
|
||||
if $SYSTEM_MODE; then
|
||||
echo " sudo systemctl list-timers 'sky-cam-*'"
|
||||
echo " sudo journalctl -u sky-cam-4seasons.service -f"
|
||||
echo " sudo journalctl -u sky-cam-seasons-${CAMERAS[0]}.service -f"
|
||||
else
|
||||
echo " systemctl --user list-timers 'sky-cam-*'"
|
||||
echo " journalctl --user -u sky-cam-4seasons.service -f"
|
||||
echo " journalctl --user -u sky-cam-seasons-${CAMERAS[0]}.service -f"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user