mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-17 18:07:46 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4917c97076 | ||
|
|
33fc647cb1 | ||
|
|
abec27c38a | ||
|
|
082b0f4c7c | ||
|
|
8521280070 | ||
|
|
0aac94f27c |
@@ -17,6 +17,8 @@
|
|||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.4.6**: Compatibility changes to timeout, due to busybox.
|
||||||
|
- **v0.4.5**: Bugfixes, compatibility changes to timeout and arrays.
|
||||||
- **v0.4.3**: Added timeout option to skip container if registry check takes too long (10s default).
|
- **v0.4.3**: Added timeout option to skip container if registry check takes too long (10s default).
|
||||||
- **v0.4.1**: Syntax and logic cleanups, bugfixes on multi compose and env-files.
|
- **v0.4.1**: Syntax and logic cleanups, bugfixes on multi compose and env-files.
|
||||||
- **v0.4.0**: Reworked selfupdate (auto git/curl/wget), general syntax cleanup, added -v for version.
|
- **v0.4.0**: Reworked selfupdate (auto git/curl/wget), general syntax cleanup, added -v for version.
|
||||||
@@ -76,6 +78,7 @@ ___
|
|||||||
|
|
||||||
## :nut_and_bolt: Dependencies
|
## :nut_and_bolt: Dependencies
|
||||||
- Running docker (duh) and compose, either standalone or plugin.
|
- Running docker (duh) and compose, either standalone or plugin.
|
||||||
|
- Bash shell or compatible shell of at least v4.3
|
||||||
- [regclient/regctl](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0))
|
- [regclient/regctl](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0))
|
||||||
- User will be prompted to download `regctl` if not in `PATH` or `PWD`.
|
- User will be prompted to download `regctl` if not in `PATH` or `PWD`.
|
||||||
- regctl requires `amd64/arm64` - see [workaround](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used.
|
- regctl requires `amd64/arm64` - see [workaround](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used.
|
||||||
|
|||||||
27
dockcheck.sh
27
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.4.4"
|
VERSION="v0.4.6"
|
||||||
### ChangeNotes: Bugfix for non amd64/arm64 arch with new timeout function.
|
### ChangeNotes: Compatability changes due to busyboxs timemout.
|
||||||
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"
|
||||||
|
|
||||||
@@ -217,6 +217,17 @@ fi
|
|||||||
DocCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l)
|
DocCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l)
|
||||||
RegCheckQue=0
|
RegCheckQue=0
|
||||||
|
|
||||||
|
### Testing and setting timeout binary
|
||||||
|
t_out=$(type -P "timeout")
|
||||||
|
if [[ $t_out ]]; then
|
||||||
|
t_out=$(realpath $t_out 2>/dev/null || readlink -f $t_out)
|
||||||
|
if [[ $t_out =~ "busybox" ]]; then
|
||||||
|
t_out="timeout ${Timeout}"
|
||||||
|
else t_out="timeout --foreground ${Timeout}"
|
||||||
|
fi
|
||||||
|
else t_out=""
|
||||||
|
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 $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
|
||||||
((RegCheckQue+=1))
|
((RegCheckQue+=1))
|
||||||
@@ -225,8 +236,8 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
|
|||||||
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
||||||
### Checking for errors while setting the variable:
|
# Checking for errors while setting the variable:
|
||||||
if RegHash=$(timeout --foreground ${Timeout} $regbin image digest --list "$RepoUrl" 2>&1) ; then
|
if RegHash=$(${t_out} $regbin image digest --list "$RepoUrl" 2>&1) ; then
|
||||||
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
||||||
NoUpdates+=("$i")
|
NoUpdates+=("$i")
|
||||||
else
|
else
|
||||||
@@ -243,9 +254,11 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
|
|||||||
done
|
done
|
||||||
|
|
||||||
### Sort arrays alphabetically
|
### Sort arrays alphabetically
|
||||||
readarray -td '' NoUpdates < <(printf '%s\0' "${NoUpdates[@]}" | sort -z -n)
|
IFS=$'\n'
|
||||||
readarray -td '' GotUpdates < <(printf '%s\0' "${GotUpdates[@]}" | sort -z -n)
|
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
|
||||||
readarray -td '' GotErrors < <(printf '%s\0' "${GotErrors[@]}" | sort -z -n)
|
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
|
||||||
### Define how many updates are available
|
### Define how many updates are available
|
||||||
UpdCount="${#GotUpdates[@]}"
|
UpdCount="${#GotUpdates[@]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user