diff --git a/_update/update.sh b/_update/update.sh index d5016a4..a158c03 100755 --- a/_update/update.sh +++ b/_update/update.sh @@ -18,7 +18,7 @@ notify() { : > "$LOG_FILE" log "Starting image update check" -updated=(); failed=() +updated=(); failed=(); checked=0 for stack_dir in "$STACKS_DIR"/*/; do stack=$(basename "$stack_dir") @@ -27,9 +27,13 @@ for stack_dir in "$STACKS_DIR"/*/; do log "Checking $stack" cd "$stack_dir" - pull_output=$(docker compose pull 2>&1 | tee -a "$LOG_FILE") + checked=$((checked + 1)) - if echo "$pull_output" | grep -q " Pulled"; then + before=$(docker compose images -q 2>/dev/null | sort) + docker compose pull 2>&1 | tee -a "$LOG_FILE" + after=$(docker compose images -q 2>/dev/null | sort) + + if [ "$before" != "$after" ]; then log " Updates found — recreating containers" if docker compose up -d 2>&1 | tee -a "$LOG_FILE"; then updated+=("$stack") @@ -45,12 +49,14 @@ done log "Pruning dangling images" docker image prune -f 2>&1 | tee -a "$LOG_FILE" -if [ ${#updated[@]} -eq 0 ] && [ ${#failed[@]} -eq 0 ]; then - notify "#36a64f" "✅ **Update check complete** — all images up to date" -elif [ ${#failed[@]} -gt 0 ]; then - notify "#cc0000" "❌ **Update failed**\nUpdated: ${updated[*]:-none}\nFailed: ${failed[*]}" +date_str=$(date '+%Y-%m-%d %H:%M') + +if [ ${#failed[@]} -gt 0 ]; then + notify "#cc0000" "❌ **Update failed** — $date_str\nUpdated: ${updated[*]:-none}\nFailed: ${failed[*]}" +elif [ ${#updated[@]} -gt 0 ]; then + notify "#36a64f" "✅ **Updates applied** — $date_str\nStacks updated (${#updated[@]}/$checked): ${updated[*]}" else - notify "#36a64f" "✅ **Updates applied**\nStacks: ${updated[*]}" + notify "#36a64f" "✅ **All up to date** — $date_str ($checked stacks checked)" fi log "Update check complete"