Skip to content

Commit

Permalink
Changed datecheck logic.
Browse files Browse the repository at this point in the history
Printing how old in days a skipped "too new" image is.
  • Loading branch information
mag37 committed Dec 14, 2023
1 parent 7bd5f87 commit fbd27d6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dockcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Help() {
echo "-a|y Automatic updates, without interaction."
echo "-n No updates, only checking availability."
echo "-e X Exclude containers, separated by comma."
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix. 2xSlower."
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
echo "-p Auto-Prune dangling images after update."
echo "-r Allow updating images for docker run, wont update the container"
echo "-s Include stopped containers in the check. (Logic: docker ps -a)"
Expand Down Expand Up @@ -106,9 +106,9 @@ choosecontainers() {
}

datecheck() {
DaysAgo=$(date -d "$DaysOld days ago" +"%Y-%m-%d")
ImageDate=$($regbin image inspect "$RepoUrl" --format='{{.Created}}' | cut -d" " -f1 )
if [ $(date -d "$ImageDate" +%s) -le $(date -d "$DaysAgo" +%s) ] ; then
ImageAge=$((($(date +%s) - $(date -d "$ImageDate" +%s))/86400))
if [ $ImageAge -gt $DaysOld ] ; then
return 0
else
return 1
Expand Down Expand Up @@ -190,7 +190,7 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
NoUpdates+=("$i")
else
if [[ -n "$DaysOld" ]] && ! datecheck ; then
NoUpdates+=("+$i")
NoUpdates+=("+$i ${ImageAge}d")
else
GotUpdates+=("$i")
fi
Expand Down

0 comments on commit fbd27d6

Please sign in to comment.