From a25e6485571f9c519e744b4c099ecf8d31db1ee6 Mon Sep 17 00:00:00 2001 From: mag37 Date: Wed, 21 Jun 2023 20:09:31 +0200 Subject: [PATCH] Changes to the Exclude-option to only exclude exact matches. --- dockcheck.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index c7ae908..dc13da5 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="v0.2.3" -### ChangeNotes: Added self-updating git/curl-function and a dirty changenote. +VERSION="v0.2.4" +### ChangeNotes: Fixes to the Exclude-option to only exclude exact matches. Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" @@ -154,9 +154,17 @@ for i in "${GotUpdates[@]}"; do done } +### Listing typed exclusions: +if [[ -n ${Excludes[*]} ]] ; then + printf "\n\033[0;34mExcluding these names:\033[0m\n" + printf "%s\n" "${Excludes[@]}" + printf "\n" +fi + ### Check the image-hash of every running container VS the registry for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do - [[ " ${Excludes[*]} " =~ ${i} ]] && continue; # Skip if the container is excluded + ### Looping every item over the list of excluded names and skipping: + for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done printf ". " RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}') LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')