mirror of
https://github.com/mag37/dockcheck.git
synced 2026-02-15 07:48:14 +01:00
Update dockcheck.sh
Did some changes to the logic, cleaned some whitespace.
This commit is contained in:
parent
f91ca08d54
commit
5dc9af9874
1 changed files with 9 additions and 21 deletions
30
dockcheck.sh
30
dockcheck.sh
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.2.4"
|
VERSION="v0.2.5"
|
||||||
### ChangeNotes: Fixes to the Exclude-option to only exclude exact matches. +cleaning
|
### ChangeNotes: Added an -s option to include stopped contianers in the check.
|
||||||
Github="https://github.com/mag37/dockcheck"
|
Github="https://github.com/mag37/dockcheck"
|
||||||
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
||||||
|
|
||||||
|
|
@ -25,18 +25,19 @@ Help() {
|
||||||
echo "-n No updates, only checking availability."
|
echo "-n No updates, only checking availability."
|
||||||
echo "-e Exclude containers, separated by comma."
|
echo "-e Exclude containers, separated by comma."
|
||||||
echo "-p Auto-Prune dangling images after update."
|
echo "-p Auto-Prune dangling images after update."
|
||||||
echo "-s Check stopped containers"
|
echo "-r Allow updating images for docker run, wont update the container"
|
||||||
echo "-r Allow updating images for docker run, wont update the container"
|
echo "-s Include stopped containers in the check. (Logic: docker ps -a)"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "aynprhse:" options; do
|
Stopped=""
|
||||||
|
while getopts "aynprhse:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) UpdYes="yes" ;;
|
a|y) UpdYes="yes" ;;
|
||||||
n) UpdYes="no" ;;
|
n) UpdYes="no" ;;
|
||||||
r) DrUp="yes" ;;
|
r) DrUp="yes" ;;
|
||||||
p) PruneQ="yes" ;;
|
p) PruneQ="yes" ;;
|
||||||
e) Exclude=${OPTARG} ;;
|
e) Exclude=${OPTARG} ;;
|
||||||
s) Stopped="yes" ;;
|
s) Stopped="-a" ;;
|
||||||
h|*) Help ; exit 0 ;;
|
h|*) Help ; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
@ -163,18 +164,9 @@ if [[ -n ${Excludes[*]} ]] ; then
|
||||||
printf "\n"
|
printf "\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$Stopped" == "yes" ]; then
|
|
||||||
Cadena="$(docker ps -a --filter "name=$SearchName" --format '{{.Names}}')";
|
|
||||||
|
|
||||||
else
|
|
||||||
Cadena="$(docker ps --filter "name=$SearchName" --format '{{.Names}}')";
|
|
||||||
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
### Check the image-hash of every running container VS the registry
|
### Check the image-hash of every running container VS the registry
|
||||||
for i in ${Cadena} ; do
|
for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
||||||
### Looping every item over the list of excluded names and skipping:
|
### Looping every item over the list of excluded names and skipping:
|
||||||
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
||||||
printf ". "
|
printf ". "
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
|
|
@ -187,10 +179,6 @@ for i in ${Cadena} ; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Sort arrays alphabetically
|
### Sort arrays alphabetically
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
|
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue