From 4505cbac6360bb3cbfe9a7aa0729989db176f608 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 1 Mar 2026 18:45:25 +0100 Subject: [PATCH] Add auto-prune to be possible without any other interactions. --- dockcheck.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index c7acfef..b607583 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -705,7 +705,7 @@ if [[ -n "${GotUpdates:-}" ]]; then # Trigger pruning only when backup-function is not used if [[ -z "${BackupForDays:-}" ]]; then if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune all dangling images? y/[n]: " AutoPrune; fi - if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\nAuto pruning.."; docker image prune -f; fi + if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\nAuto pruning.."; docker image prune -f && AlreadyPruned="true" ; fi fi else @@ -715,7 +715,11 @@ else printf "\nNo updates available.\n" fi -# Clean up old backup image tags if -b is used -[[ -n "${BackupForDays:-}" ]] && remove_backups +# Clean up old backup image tags if -b is used otherwise prune if auto-prune is set +if [[ -n "${BackupForDays:-}" ]]; then + remove_backups +else + if [[ "$AutoPrune" == true ]] && [[ "${AlreadyPruned:=false}" != true ]]; then printf "\nAuto pruning.."; docker image prune -f; fi +fi exit 0