Skip redundant restart for containers docker_update.sh already rebuilt

docker_update.sh rebuilds (stop+recreate) any container whose image
changed, in every mode — but for daily/weekly that was always followed
by the restart script's own unconditional pass, stopping and starting
the same container twice back to back. docker_update.sh now records
which containers it rebuilt this run to a file; docker_daily_restart.sh
and docker_weekly_restart.sh read it and skip those specifically,
still restarting everything else as before. A file older than
DOCKER_UPDATE_REBUILT_STALE_HOURS (default 12) is discarded rather
than trusted, so a missed or failed update run can't suppress a
restart indefinitely.
This commit is contained in:
Gmer4Lfe
2026-07-19 16:09:55 -04:00
parent 7252d4aad3
commit 9425d16c19
4 changed files with 110 additions and 3 deletions
+21
View File
@@ -106,6 +106,13 @@
# MONTHLY_REMAINING_UPDATES
# Enable or disable remainder mode. (default: true)
#
# DOCKER_UPDATE_REBUILT_DAILY_FILE / DOCKER_UPDATE_REBUILT_WEEKLY_FILE
# Written after each normal/weekly run with the containers actually rebuilt
# this pass — read by docker_daily_restart.sh / docker_weekly_restart.sh so
# they skip restarting a container a second time right after this script
# already rebuilt it onto the new image. Not written in remainder mode
# (no follow-up restart script exists for it).
#
# PROFILE_CRITICAL_CONTAINER_NAMES[emby|critical-data]
# Container names for emby and critical-data profiles — excluded from
# remainder mode (already updated by the weekly sync window)
@@ -406,6 +413,20 @@ if [[ ${#UPDATED[@]} -gt 0 ]]; then
done
fi
# Record successfully-rebuilt containers so the follow-up restart script (daily/weekly only —
# remainder has no follow-up) can skip them instead of restarting an already-fresh container a
# second time. Deliberately excludes REBUILD_FAILED — those still need the restart script's
# normal pass as a fallback, exactly as the error message above promises. Written even when
# REBUILT is empty, so a stale file from a previous run doesn't linger and get misread later.
if [[ "$DRY_RUN" == false && "$REMAINDER_MODE" != true ]]; then
_rebuilt_file="$DOCKER_UPDATE_REBUILT_DAILY_FILE"
[[ "$WEEKLY_MODE" == true ]] && _rebuilt_file="$DOCKER_UPDATE_REBUILT_WEEKLY_FILE"
if [[ -n "$_rebuilt_file" ]]; then
printf '%s\n' "${REBUILT[@]}" > "$_rebuilt_file" 2>/dev/null
fi
unset _rebuilt_file
fi
# ── Remove old images ────────────────────────────────────────────────────────
# Explicitly rmi by the IDs captured before each pull. Tagged images are never
# caught by dangling-only prune, so this is the only reliable cleanup path.