From fbd27d6e3758d5e8e3647c6aa48a53d06da25d41 Mon Sep 17 00:00:00 2001 From: mag37 Date: Thu, 14 Dec 2023 09:06:19 +0100 Subject: [PATCH] Changed datecheck logic. Printing how old in days a skipped "too new" image is. --- dockcheck.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 823d3a5..e217855 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -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)" @@ -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 @@ -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