Fix container updates: rebuild on new image, consolidate update scripts

Weekly sync window was pulling images but using docker start after rsync,
which ignores the new digest. Containers in the emby/critical-data profiles
(Emby, Mariadb, Redis) never actually landed on updated images.

docker_update_remaining.sh merged into docker_update.sh --remainder, which
already had better exclusion logic. Added WEEKLY_REMAINING_UPDATES toggle
and WEEKLY_RESTART_CONTAINERS exclusion to remainder mode.

Onboard now runs docker_network_connect.sh on mirror before deploying stacks.
This commit is contained in:
Gmer4Lfe
2026-06-14 10:58:19 -04:00
parent ba3eed39e3
commit fdef61cc25
5 changed files with 92 additions and 349 deletions
+41 -3
View File
@@ -12,7 +12,7 @@
# 4. Pull updates remotely — if WEEKLY_SYNC_UPDATES_REMOTE=true
# 5. rsync WEEKLY_SYNC_SHARES — full clean mirror, containers stopped both sides
# 6. Start remote containers — correct order, delayed start respected
# 7. Start local containers — correct order, delayed start respected
# 7. Start local containers — rebuild if new image pulled, docker start otherwise
# 8. WEEKLY_MAINTENANCE_SCRIPTS — weekly restarts etc. (docker_weekly_restart.sh)
# 9. docker_update.sh --remainder — update all containers not in daily or weekly sync window
#
@@ -203,6 +203,8 @@ fi
echo ""
echo "━━━ $ICON_GEAR Container Updates ━━━"
declare -A _weekly_needs_rebuild=()
if [[ "$WEEKLY_SYNC_UPDATES" == true ]]; then
if [[ "$DRY_RUN" == true ]]; then
for c in "${MAINTENANCE_CONTAINERS[@]}"; do
@@ -218,13 +220,21 @@ if [[ "$WEEKLY_SYNC_UPDATES" == true ]]; then
log "$c — not found locally, skipping update"
continue
fi
_old_id=$(docker image inspect "$IMAGE" --format='{{.Id}}' 2>/dev/null || echo "")
log "Pulling $IMAGE for $c..."
if docker pull "$IMAGE" >/dev/null 2>&1; then
log "$c — image updated ✅"
_new_id=$(docker image inspect "$IMAGE" --format='{{.Id}}' 2>/dev/null || echo "")
if [[ -n "$_old_id" && "$_old_id" != "$_new_id" ]]; then
log "$c — new image (${_old_id:7:12}${_new_id:7:12}) — will rebuild after sync"
_weekly_needs_rebuild["$c"]=1
else
log "$c — already current"
fi
else
warn "$c — pull failed, will start on existing image"
fi
done
unset _old_id _new_id
fi
else
echo "WEEKLY_SYNC_UPDATES=false — skipping local updates"
@@ -316,7 +326,35 @@ if [[ "$DRY_RUN" == true ]]; then
warn "DRY RUN — containers will not be started"
else
start_containers
start_local_containers
# Local start — rebuild containers that received a new image, docker start the rest
if [[ ${#LOCAL_RUNNING_CONTAINERS[@]} -eq 0 ]]; then
log "No local containers to restart."
else
for _c in "${LOCAL_RUNNING_CONTAINERS[@]}"; do
[[ -z "$_c" ]] && continue
_needs_delay=false
for _d in "${DELAYED_CONTAINERS[@]}"; do
[[ "$_c" == "$_d" ]] && _needs_delay=true && break
done
[[ "$_needs_delay" == true ]] && {
info "Waiting ${CONTAINER_DELAY}s before starting $_c..."
sleep "$CONTAINER_DELAY"
}
if [[ -n "${_weekly_needs_rebuild[$_c]:-}" ]]; then
log "Rebuilding $_c on new image..."
if platform_rebuild_container "$_c"; then
log "$_c rebuilt on new image ✅"
else
warn "$_c rebuild failed — falling back to docker start"
docker start "$_c" >/dev/null 2>&1 || error "Failed to start $_c"
fi
else
docker start "$_c" >/dev/null 2>&1 && log "$_c started" || error "Failed to start $_c"
fi
done
unset _c _d _needs_delay
fi
fi
# ==============================================================================================