Rename dockcheck_function.sh to dc_function.sh

changed name
This commit is contained in:
mag37 2023-01-18 21:20:49 +01:00 committed by GitHub
parent ffebbd5465
commit 72f00fdf9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

22
dc_function.sh Normal file
View file

@ -0,0 +1,22 @@
#!/bin/bash
### Requires the regctl binary, either in PATH or as an alias
### Get it here: https://github.com/regclient/regclient/releases
### Preferably placed in .bashrc or similar
### if regctl is not in PATH, set the alias:
alias regctl="/path/to/regctl"
dockcheck () {
if [[ -z "$1" ]]; then
echo "No container name given, here's the list of currently running containers:"
docker ps --format '{{.Names}}'
else
RepoUrl=$(docker inspect "$1" --format='{{.Config.Image}}')
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}' | sed -e 's/.*sha256/sha256/' -e 's/\]$//')
RegHash=$(regctl image digest --list "$RepoUrl")
if [[ "$LocalHash" != "$RegHash" ]] ; then printf "Updates available.\n" ; else printf "Already latest.\n" ; fi
fi
}