mirror of
https://github.com/mag37/dockcheck.git
synced 2026-02-17 16:58:14 +01:00
moved the cleanup and prune logic to always run. Changed some wording on messages.
This commit is contained in:
parent
42d35b7a03
commit
6576a36fda
1 changed files with 24 additions and 20 deletions
44
dockcheck.sh
44
dockcheck.sh
|
|
@ -638,30 +638,34 @@ if [[ -n "${GotUpdates:-}" ]]; then
|
||||||
${DockerBin} ${CompleteConfs} ${ContEnvs} up -d ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
|
${DockerBin} ${CompleteConfs} ${ContEnvs} up -d ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Clean up old backup image tags if -k is used
|
|
||||||
if [[ -n "${DaysKept:-}" ]]; then
|
|
||||||
IFS=$'\n'
|
|
||||||
for backup_img in $(docker images --format "{{.Repository}} {{.Tag}}" dockcheck/\*); do
|
|
||||||
repo_name=${backup_img% *}
|
|
||||||
backup_tag=${backup_img#* }
|
|
||||||
backup_date=${backup_tag%%_*}
|
|
||||||
# UNTAGGING HERE
|
|
||||||
if datecheck "$backup_date" "$DaysKept"; then
|
|
||||||
docker rmi "${repo_name}:${backup_tag}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
unset IFS
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if [[ "$AutoPrune" == false ]] && [[ "$AutoMode" == false ]]; then printf "\n"; read -rep "Would you like to prune all dangling images? y/[n]: " AutoPrune; fi
|
printf "\n%bAll updates done!%b\n" "$c_green" "$c_reset"
|
||||||
if [[ "$AutoPrune" == true ]] || [[ "$AutoPrune" =~ [yY] ]]; then printf "\nAuto pruning.."; docker image prune -f; fi
|
|
||||||
printf "\n%bAll done!%b\n" "$c_green" "$c_reset"
|
|
||||||
else
|
else
|
||||||
printf "\nNo updates installed, exiting.\n"
|
printf "\nNo updates installed.\n"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf "\nNo updates available, exiting.\n"
|
printf "\nNo updates available.\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up old backup image tags if -k is used
|
||||||
|
if [[ -n "${DaysKept:-}" ]]; then
|
||||||
|
IFS=$'\n'
|
||||||
|
CleanupCount=0
|
||||||
|
for backup_img in $(docker images --format "{{.Repository}} {{.Tag}}" dockcheck/\*); do
|
||||||
|
repo_name=${backup_img% *}
|
||||||
|
backup_tag=${backup_img#* }
|
||||||
|
backup_date=${backup_tag%%_*}
|
||||||
|
# UNTAGGING HERE
|
||||||
|
if datecheck "$backup_date" "$DaysKept"; then
|
||||||
|
[[ "$CleanupCount" == 0 ]] && echo "Removing backed up images older then $DaysKept days."
|
||||||
|
docker rmi "${repo_name}:${backup_tag}" && ((CleanupCount+=1))
|
||||||
|
fi
|
||||||
|
[[ "$CleanupCount" == 0 ]] && printf "No backup images to remove.%b\n" || printf "%b%s%b backup images removed." "$c_blue" "$c_teal" "$CleanupCount" "$c_reset"
|
||||||
|
done
|
||||||
|
unset IFS
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue