From d877a862927349ca28af2a5e87d41db247bb2c91 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 26 Feb 2023 08:03:15 +0100 Subject: [PATCH] Added exclude-opt Added options to allow for exclude option to be used --- dc_brief.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) mode change 100644 => 100755 dc_brief.sh diff --git a/dc_brief.sh b/dc_brief.sh old mode 100644 new mode 100755 index 208e0dd..5935b8a --- a/dc_brief.sh +++ b/dc_brief.sh @@ -2,9 +2,21 @@ ### If not in PATH, set full path. Else just "regctl" regbin="regctl" +### options to allow exclude: +while getopts "e:" options; do + case "${options}" in + e) Exclude=${OPTARG} ;; + *) exit 0 ;; + esac +done +shift "$((OPTIND-1))" +### Create array of excludes +IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS + SearchName="$1" for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do + [[ " ${Excludes[*]} " =~ ${i} ]] && continue; # Skip if the container is excluded printf ". " RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}') LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')