diff --git a/bin/.bin/webcam-build-timelapses b/bin/.bin/webcam-build-timelapses index 66de1e1..c4134db 100755 --- a/bin/.bin/webcam-build-timelapses +++ b/bin/.bin/webcam-build-timelapses @@ -32,7 +32,7 @@ WEBCAMS=( TIMELAPSE_SCRIPT="/usr/local/bin/make_timelapse" NTFY_URL="https://ntfy.unbl.ink/timelapse" -WEB_PREFIX="https://files.lab.unbl.ink" +WEB_PREFIX="https://files.lab.unbl.ink/webcams" # ---------------- # Yesterday's date @@ -63,56 +63,45 @@ for cam in "${WEBCAMS[@]}"; do fi done -# --- Update HTML index --- -mkdir -p "$BASE_DIR" -if [[ ! -f "$INDEX_FILE" ]]; then - cat >"$INDEX_FILE" < "$INDEX_HTML" < - + Webcam Timelapses -

Webcam Timelapses

+
+
EOF fi -# Insert new section for yesterday at the top -TMP=$(mktemp) -{ - echo "

$YESTERDAY

" - echo "" - echo "
" -} >"$TMP" +# Build new day's section +NEW_SECTION="

$YESTERDAY

" -# Place new block after

line -awk -v block="$(cat "$TMP")" ' - /

/ { print; getline; print; print block; next } +# Insert at the top of
+tmpfile=\$(mktemp) +awk -v section="\$NEW_SECTION" ' + /
/ { print; print section; next } { print } -' "$INDEX_FILE" >"$INDEX_FILE.new" +' "\$INDEX_HTML" > "\$tmpfile" +mv "\$tmpfile" "\$INDEX_HTML" -mv "$INDEX_FILE.new" "$INDEX_FILE" -rm "$TMP" - -echo "📄 Updated HTML index: $INDEX_FILE" +echo "📝 Updated index with $YESTERDAY timelapses (newest on top)" # --- Send combined notification --- if [[ -n "$NTFY_URL" ]] && [[ ${#LINKS[@]} -gt 0 ]]; then