-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQUEST] Minimal Output #72
Comments
I'm not entirely sure what your wished output should look like. But in the I'll gladly try to help you out. Maybe this is a start? Wont show progress, just the list of containers with updates available when done. #!/usr/bin/env bash
### 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
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
### Checking for errors while setting the variable:
if RegHash=$($regbin image digest --list "$RepoUrl" 2>/dev/null) ; then
if [[ "$LocalHash" = *"$RegHash"* ]] ; then NoUpdates+=("$i"); else GotUpdates+=("$i"); fi
else
GotErrors+=("$i")
fi
done
### Sort arrays alphabetically
IFS=$'\n'
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
GotErrors=($(sort <<<"${GotErrors[*]}"))
unset IFS
if [[ -n ${GotUpdates[*]} ]] ; then
printf "%s\n" "${GotUpdates[@]}"
fi Or you could write them to a file if you'd like, just replace the last bit |
Couldn't he use notify_generic.sh and tweak it to print exactly what he wants in an easy to grep form? |
In truth, I didn't notice the Extras folder entirely :V DC_Brief seems like it'd be the easiest option for this, but it doesn't seem to work on my system. Just outputs the containers that cannot update due to errors, and nothing after that. I tried your provided script as well, but that didn't output anything at all. Renaming notify_generic to just notify.sh doesn't seem to apply it properly for me either, it never prints anything more than Dockcheck does. |
Don't forget the -i to turn on information notification. If you have no outdated containers the notification doesn't get called at all. sudo dockcheck.sh -n -s -i
I tweaked the print statement to include the number of outdated containers as follows. If you improve the notify_generic.sh file the dev may merge your changes. |
Well that sounds like it's probably due to not editing the
Odd - even when you run the script with the flags Also if I understand you correctly you'd just like the number of containers as a plain number as the result?
If you use the notify.sh you would still get the output of the script, so that's not very clean. But could be done with just pasting this code in a new file called
But to just get the number as an output, I'd use what I pasted above (a modification of the |
Ah, christ. That's embarassing. I forgot that the main script handled regctl automatically. |
This script looks like the perfect solution for what I'm trying to put together.
I have a Grafana Dashboard that lists details about my running containers and host system. I'd like to have a panel that counts how many containers currently have updates available to download.
Dockcheck handles the majority of the work, but it's difficult to pull the data I need out of it after. I can't seem to be able to grab anything with Echo or Awk, though my Bash knowledge is extremely beginner. Would it be possible to add a Minimal Output mode, that just prints the containers with updates available to stdout, and nothing else?
The text was updated successfully, but these errors were encountered: