Skip to content

Commit

Permalink
Merge pull request #84 from mag37/busyfix
Browse files Browse the repository at this point in the history
Compat fixes for busyboxs timeout.
  • Loading branch information
mag37 authored Jun 16, 2024
2 parents 082b0f4 + 33fc647 commit 4917c97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
___
## :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.1**: Syntax and logic cleanups, bugfixes on multi compose and env-files.
Expand Down Expand Up @@ -77,6 +78,7 @@ ___

## :nut_and_bolt: Dependencies
- 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))
- 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.
Expand Down
17 changes: 13 additions & 4 deletions dockcheck.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERSION="v0.4.5"
### ChangeNotes: Compatability changes to arrays and timeout.
VERSION="v0.4.6"
### ChangeNotes: Compatability changes due to busyboxs timemout.
Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"

Expand Down Expand Up @@ -217,6 +217,17 @@ fi
DocCount=$(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}' | wc -l)
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
for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
((RegCheckQue+=1))
Expand All @@ -225,8 +236,6 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
# Setting timeout-binary if existing
if [[ $(builtin type -P "timeout") ]]; then t_out="timeout --foreground ${Timeout}"; else t_out=""; fi
# Checking for errors while setting the variable:
if RegHash=$(${t_out} $regbin image digest --list "$RepoUrl" 2>&1) ; then
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
Expand Down

0 comments on commit 4917c97

Please sign in to comment.