Compare commits

...

8 Commits

Author SHA1 Message Date
mag37
082b0f4c7c Merge pull request #82 from mag37/tfix
compat-fixes for timeout and array sorting.
2024-06-12 20:54:30 +02:00
mag37
8521280070 compat-fixes to arrays 2024-06-12 20:50:10 +02:00
mag37
0aac94f27c bugfix non coreutils 2024-06-10 21:09:04 +02:00
mag37
730dba5c3d version bump - bugfix 2024-06-08 19:44:14 +02:00
mag37
f8455d3787 bugfix for non amd64/arm64 arch.
added --foreground to timeout.
2024-06-08 19:43:12 +02:00
mag37
bbe9164554 versionbump 2024-06-03 22:53:10 +02:00
mag37
5d86c79710 Update dockcheck.sh
versionbump for fix
2024-06-03 22:50:07 +02:00
mag37
b0f8431dbf Update dockcheck.sh
timeout default fix
2024-06-03 22:49:14 +02:00
2 changed files with 15 additions and 9 deletions

View File

@@ -17,7 +17,8 @@
___ ___
## :bell: Changelog ## :bell: Changelog
- **v0.4.2**: Added timeout option to skip container if registry check takes too long (10s default). - **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. - **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.
- **v0.3.8**: Fixed `--env-file` logic to work with multiple env-files. - **v0.3.8**: Fixed `--env-file` logic to work with multiple env-files.

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.4.2" VERSION="v0.4.5"
### ChangeNotes: Added timeout option to skip container if registry check takes too long (10s default). ### ChangeNotes: Compatability changes to arrays and timeout.
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"
@@ -44,6 +44,7 @@ c_blue="\033[0;34m"
c_teal="\033[0;36m" c_teal="\033[0;36m"
c_reset="\033[0m" c_reset="\033[0m"
Timeout=10
Stopped="" Stopped=""
while getopts "aynpfrhlisvme:d:t:" options; do while getopts "aynpfrhlisvme:d:t:" options; do
case "${options}" in case "${options}" in
@@ -57,7 +58,7 @@ while getopts "aynpfrhlisvme:d:t:" options; do
e) Exclude=${OPTARG} ;; e) Exclude=${OPTARG} ;;
m) declare c_{red,green,yellow,blue,teal,reset}="" ;; m) declare c_{red,green,yellow,blue,teal,reset}="" ;;
s) Stopped="-a" ;; s) Stopped="-a" ;;
t) Timeout="${OPTARG:-10}" ;; t) Timeout="${OPTARG}" ;;
v) printf "%s\n" "$VERSION" ; exit 0 ;; v) printf "%s\n" "$VERSION" ; exit 0 ;;
d) DaysOld=${OPTARG} d) DaysOld=${OPTARG}
if ! [[ $DaysOld =~ ^[0-9]+$ ]] ; then { printf "Days -d argument given (%s) is not a number.\n" "${DaysOld}" ; exit 2 ; } ; fi ;; if ! [[ $DaysOld =~ ^[0-9]+$ ]] ; then { printf "Days -d argument given (%s) is not a number.\n" "${DaysOld}" ; exit 2 ; } ; fi ;;
@@ -224,8 +225,10 @@ 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: # Setting timeout-binary if existing
if RegHash=$(timeout ${Timeout} $regbin image digest --list "$RepoUrl" 2>&1) ; then 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 if [[ "$LocalHash" = *"$RegHash"* ]] ; then
NoUpdates+=("$i") NoUpdates+=("$i")
else else
@@ -242,9 +245,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[@]}"