mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 02:17:46 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a8571c625 | ||
|
|
710cbc118f | ||
|
|
68ec749c39 | ||
|
|
778df1de3c |
@@ -21,6 +21,10 @@
|
|||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.6.1**: Hotfixes: (try removing set+shopt+shopt if debugging more errors)
|
||||||
|
- xargs/pipefail, removed `-set -e` bash option for now.
|
||||||
|
- unbound variables fixed (hopefully)
|
||||||
|
- dependency installer from pkgmanager rewritten
|
||||||
- **v0.6.0**: Refactored a lot of code, cleaner logic and syntax, safer variables.
|
- **v0.6.0**: Refactored a lot of code, cleaner logic and syntax, safer variables.
|
||||||
- Safer bash options with `set -euo pipefail`, `shopt -s nullglob` and `failglob`.
|
- Safer bash options with `set -euo pipefail`, `shopt -s nullglob` and `failglob`.
|
||||||
- Added a `default.conf` for user settings - persistent through updates.
|
- Added a `default.conf` for user settings - persistent through updates.
|
||||||
|
|||||||
34
dockcheck.sh
34
dockcheck.sh
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.6.0"
|
VERSION="v0.6.1"
|
||||||
### ChangeNotes: uservars file added. Lots of code refactoring, please report any bugs.
|
### ChangeNotes: Hotfix - bug with xargs pipefail, pkgmanager logic, unbound variables
|
||||||
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"
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
shopt -s failglob
|
shopt -s failglob
|
||||||
|
|
||||||
@@ -269,12 +269,16 @@ dependency_check() {
|
|||||||
[[ "$GetBin" =~ [yY] ]] && distro_checker
|
[[ "$GetBin" =~ [yY] ]] && distro_checker
|
||||||
if [[ -n "${PkgInstaller:-}" && "${PkgInstaller:-}" != "ERROR" ]]; then
|
if [[ -n "${PkgInstaller:-}" && "${PkgInstaller:-}" != "ERROR" ]]; then
|
||||||
[[ $(uname -s) == "Darwin" && "$AppName" == "regctl" ]] && AppName="regclient"
|
[[ $(uname -s) == "Darwin" && "$AppName" == "regctl" ]] && AppName="regclient"
|
||||||
("$PkgInstaller" "$AppName"); PkgExitcode="$?" && AppName="$1"
|
if $PkgInstaller "$AppName"; then
|
||||||
if [[ "$PkgExitcode" == 0 ]]; then { export "$AppVar"="$AppName" && printf "\n%b%b installed.%b\n" "$c_green" "$AppName" "$c_reset"; }
|
AppName="$1"
|
||||||
else printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
export "$AppVar"="$AppName"
|
||||||
|
printf "\n%b%b installed.%b\n" "$c_green" "$AppName" "$c_reset"
|
||||||
|
else
|
||||||
|
PkgExitcode="ERROR"
|
||||||
|
printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ "$GetBin" =~ [sS] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]]; then
|
if [[ "$GetBin" =~ [sS] || "$PkgInstaller" == "ERROR" ]]; then
|
||||||
binary_downloader "$AppName" "$AppUrl"
|
binary_downloader "$AppName" "$AppUrl"
|
||||||
[[ -f "$ScriptWorkDir/$AppName" ]] && { export "$AppVar"="$ScriptWorkDir/$1" && printf "\n%b%b downloaded.%b\n" "$c_green" "$AppName" "$c_reset"; }
|
[[ -f "$ScriptWorkDir/$AppName" ]] && { export "$AppVar"="$ScriptWorkDir/$1" && printf "\n%b%b downloaded.%b\n" "$c_green" "$AppName" "$c_reset"; }
|
||||||
fi
|
fi
|
||||||
@@ -322,7 +326,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Listing typed exclusions
|
# Listing typed exclusions
|
||||||
if [[ -n ${Excludes[*]} ]]; then
|
if [[ -n ${Excludes[*]:-} ]]; then
|
||||||
printf "\n%bExcluding these names:%b\n" "$c_blue" "$c_reset"
|
printf "\n%bExcluding these names:%b\n" "$c_blue" "$c_reset"
|
||||||
printf "%s\n" "${Excludes[@]}"
|
printf "%s\n" "${Excludes[@]}"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
@@ -376,7 +380,7 @@ check_image() {
|
|||||||
|
|
||||||
# Make required functions and variables available to subprocesses
|
# Make required functions and variables available to subprocesses
|
||||||
export -f check_image datecheck
|
export -f check_image datecheck
|
||||||
export Excludes_string="${Excludes[*]}" # Can only export scalar variables
|
export Excludes_string="${Excludes[*]:-}" # Can only export scalar variables
|
||||||
export t_out regbin RepoUrl DaysOld
|
export t_out regbin RepoUrl DaysOld
|
||||||
|
|
||||||
# Check for POSIX xargs with -P option, fallback without async
|
# Check for POSIX xargs with -P option, fallback without async
|
||||||
@@ -409,14 +413,14 @@ done < <( \
|
|||||||
|
|
||||||
# Sort arrays alphabetically
|
# Sort arrays alphabetically
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
|
NoUpdates=($(sort <<<"${NoUpdates[*]:-}"))
|
||||||
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
|
GotUpdates=($(sort <<<"${GotUpdates[*]:-}"))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
# Run the prometheus exporter function
|
# Run the prometheus exporter function
|
||||||
if [[ -n "${CollectorTextFileDirectory:-}" ]]; then
|
if [[ -n "${CollectorTextFileDirectory:-}" ]]; then
|
||||||
if type -t send_notification &>/dev/null; then
|
if type -t send_notification &>/dev/null; then
|
||||||
prometheus_exporter ${#NoUpdates[@]} ${#GotUpdates[@]} ${#GotErrors[@]}
|
prometheus_exporter ${#NoUpdates[@]:-} ${#GotUpdates[@]:-} ${#GotErrors[@]:-}
|
||||||
else
|
else
|
||||||
printf "%s\n" "Could not source prometheus exporter function."
|
printf "%s\n" "Could not source prometheus exporter function."
|
||||||
fi
|
fi
|
||||||
@@ -426,16 +430,16 @@ fi
|
|||||||
UpdCount="${#GotUpdates[@]}"
|
UpdCount="${#GotUpdates[@]}"
|
||||||
|
|
||||||
# List what containers got updates or not
|
# List what containers got updates or not
|
||||||
if [[ -n ${NoUpdates[*]} ]]; then
|
if [[ -n ${NoUpdates[*]:-} ]]; then
|
||||||
printf "\n%bContainers on latest version:%b\n" "$c_green" "$c_reset"
|
printf "\n%bContainers on latest version:%b\n" "$c_green" "$c_reset"
|
||||||
printf "%s\n" "${NoUpdates[@]}"
|
printf "%s\n" "${NoUpdates[@]}"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${GotErrors[*]} ]]; then
|
if [[ -n ${GotErrors[*]:-} ]]; then
|
||||||
printf "\n%bContainers with errors, won't get updated:%b\n" "$c_red" "$c_reset"
|
printf "\n%bContainers with errors, won't get updated:%b\n" "$c_red" "$c_reset"
|
||||||
printf "%s\n" "${GotErrors[@]}"
|
printf "%s\n" "${GotErrors[@]}"
|
||||||
printf "%binfo:%b 'unauthorized' often means not found in a public registry.\n" "$c_blue" "$c_reset"
|
printf "%binfo:%b 'unauthorized' often means not found in a public registry.\n" "$c_blue" "$c_reset"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${GotUpdates[*]} ]]; then
|
if [[ -n ${GotUpdates[*]:-} ]]; then
|
||||||
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
|
||||||
[[ "$AutoMode" == false ]] && options || printf "%s\n" "${GotUpdates[@]}"
|
[[ "$AutoMode" == false ]] && options || printf "%s\n" "${GotUpdates[@]}"
|
||||||
[[ "$Notify" == true ]] && { type -t send_notification &>/dev/null && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n"; }
|
[[ "$Notify" == true ]] && { type -t send_notification &>/dev/null && send_notification "${GotUpdates[@]}" || printf "Could not source notification function.\n"; }
|
||||||
|
|||||||
Reference in New Issue
Block a user