Compare commits

...

23 Commits

Author SHA1 Message Date
mag37
e6ff634394 versionbump 2025-01-28 21:55:35 +01:00
mag37
6444e18a4f Merge pull request #122 from mag37/5.3_fixes
local image check changed, Gotify-template fixed
2025-01-28 21:53:50 +01:00
mag37
14872b0471 local image check changed, Gotify-template fixed, version bump 2025-01-28 21:50:02 +01:00
mag37
07ad241e9f removed whale icon and changed redirection to still show errors 2025-01-28 21:08:20 +01:00
mag37
15ce226a0a changed local image check to reference ID instead of image-name 2025-01-22 16:07:50 +01:00
mag37
cce5438aca Update notify_DSM.sh
Ensures DSM GUI refreshes its update-check.
TY @yoyoma2 for the fix.
2024-12-01 20:51:51 +01:00
mag37
be6f5edf52 Update README.md 2024-11-25 15:23:54 +01:00
mag37
99befd6938 hotfix to changenotes.
More important that it shows for older versions than being pretty.
2024-11-24 08:46:04 +01:00
mag37
8a63fd360c hotfix 2024-11-23 14:58:15 +01:00
mag37
d3786d6f75 hotfix 2024-11-23 14:57:39 +01:00
mag37
487cfb2822 typofix jq binary 2024-11-23 14:56:15 +01:00
mag37
b4943df46c Merge pull request #111 from mag37/dependency_download_rewrite
Dependency download rewrite + jq installer
2024-11-23 12:46:38 +01:00
mag37
8603c8d4b6 Merge branch 'main' into dependency_download_rewrite 2024-11-23 12:46:15 +01:00
mag37
ae66a6f0fd ChangeNote + finalizing fixes 2024-11-23 12:40:58 +01:00
mag37
3ac0521a9b Changenotes hotfix 2024-11-22 22:52:21 +01:00
mag37
00ae250511 versionbump + jq info 2024-11-22 15:11:49 +01:00
mag37
704387a7fe versionbump + jq info 2024-11-22 15:09:16 +01:00
mag37
1a6826e2ac versionbump + jq info 2024-11-22 15:08:44 +01:00
mag37
a28b9e555f Colorized error messages 2024-11-22 14:32:30 +01:00
mag37
8309b80dc2 cleaned old jq check + fixed some naming 2024-11-22 13:45:45 +01:00
mag37
bbe26a0ac2 changes to jq install logic
Will fall back to static binary if pkgmanager install fails
or no distribution matches.
2024-11-22 13:08:24 +01:00
mag37
d98d052af7 rewrote regctl-download to use new functions 2024-11-22 11:05:16 +01:00
mag37
fbba77dc1f jq downloading functions
Added distribution checker for packagemanager installs.
Added generic static binary downloader.
2024-11-22 11:00:45 +01:00
4 changed files with 73 additions and 39 deletions

View File

@@ -18,6 +18,8 @@
___ ___
## :bell: Changelog ## :bell: Changelog
- **v0.5.3**: Local image check changed (use imageId instead of name) and Gotify-template fixed (whale icon removed).
- **v0.5.2.1**: Rewrite of dependency downloads, jq can be installed with package manager or static binary.
- **v0.5.1**: DEPENDENCY WARNING: now requires **jq**. + Upstreaming changes from [sudo-kraken/podcheck](https://github.com/sudo-kraken/podcheck) - **v0.5.1**: DEPENDENCY WARNING: now requires **jq**. + Upstreaming changes from [sudo-kraken/podcheck](https://github.com/sudo-kraken/podcheck)
- **v0.5.0**: Rewritten notify logic - all templates are adjusted and should be migrated! - **v0.5.0**: Rewritten notify logic - all templates are adjusted and should be migrated!
- Copy the custom settings from your current template to the new version of the same template. - Copy the custom settings from your current template to the new version of the same template.
@@ -26,9 +28,6 @@ ___
- Added Discord notify template. - Added Discord notify template.
- Verbosity changed of `regctl`. - Verbosity changed of `regctl`.
- **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-notifications) - **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-notifications)
- **v0.4.8**: Rewrote prune logic to not prompt with options `-a|-y` or `-n`. Auto prune with `-p`.
- **v0.4.7**: Notification Template changes to gotify(new!), DSM(improved), SMTP(deprecation alternative).
- **v0.4.6**: Compatibility changes to timeout, due to busybox.
___ ___
@@ -57,7 +56,6 @@ Options:"
-v Prints current version. -v Prints current version.
``` ```
### Basic example: ### Basic example:
``` ```
$ ./dockcheck.sh $ ./dockcheck.sh
@@ -82,6 +80,8 @@ ___
## :nut_and_bolt: Dependencies ## :nut_and_bolt: Dependencies
- Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck) - Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck)
- Bash shell or compatible shell of at least v4.3 - Bash shell or compatible shell of at least v4.3
- [jq](https://github.com/jqlang/jq)
- User will be prompted to install with package manager or download static binary.
- [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.

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.5.1" VERSION="v0.5.3.0"
# ChangeNotes: DEPENDENCY WARNING: now requires jq. And upstreaming changes from sudo-kraken/podcheck ### ChangeNotes: Bugfixes - local image check changed, Gotify-template fixed
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"
@@ -173,27 +173,64 @@ SearchName="$1"
# Create array of excludes # Create array of excludes
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
# Check if required binary exists in PATH or directory # Static binary downloader for dependencies
binary_downloader() {
BinaryName="$1"
BinaryUrl="$2"
case "$(uname --machine)" in
x86_64|amd64) architecture="amd64" ;;
arm64|aarch64) architecture="arm64";;
*) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset" ; exit 1;;
esac
GetUrl="${BinaryUrl/TEMP/"$architecture"}"
if [[ $(command -v curl) ]]; then curl -L $GetUrl > "$ScriptWorkDir/$BinaryName" ;
elif [[ $(command -v wget) ]]; then wget $GetUrl -O "$ScriptWorkDir/$BinaryName" ;
else printf "%s\n" "curl/wget not available - get $BinaryName manually from the repo link, exiting."; exit 1;
fi
[[ -f "$ScriptWorkDir/$BinaryName" ]] && chmod +x "$ScriptWorkDir/$BinaryName"
}
distro_checker() {
if [[ -f /etc/arch-release ]] ; then PkgInstaller="pacman -S"
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="dnf install"
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="zypper install"
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="apt-get install"
else PkgInstaller="ERROR" ; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
fi
}
# Dependency check for jq in PATH or directory
if [[ $(command -v jq) ]]; then jqbin="jq" ;
elif [[ -f "$ScriptWorkDir/jq" ]]; then jqbin="$ScriptWorkDir/jq" ;
else
printf "%s\n" "Required dependency 'jq' missing, do you want to install it?"
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetJq
GetJq=${GetJq:-no} # set default to no if nothing is given
if [[ "$GetJq" =~ [yYsS] ]] ; then
[[ "$GetJq" =~ [yY] ]] && distro_checker
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
(sudo $PkgInstaller jq) ; PkgExitcode="$?"
[[ "$PkgExitcode" == 0 ]] && jqbin="jq" || printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
fi
if [[ "$GetJq" =~ [nN] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
binary_downloader "jq" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
[[ -f "$ScriptWorkDir/jq" ]] && jqbin="$ScriptWorkDir/jq"
fi
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
fi
fi
# Final check if binary is correct
$jqbin --version &> /dev/null || { printf "%s\n" "jq is not working - try to remove it and re-download it, exiting."; exit 1; }
# Dependency check for regctl in PATH or directory
if [[ $(command -v regctl) ]]; then regbin="regctl" ; if [[ $(command -v regctl) ]]; then regbin="regctl" ;
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ; elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
else else
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetDep read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetRegctl
if [[ "$GetDep" =~ [yY] ]] ; then if [[ "$GetRegctl" =~ [yY] ]] ; then
# Check architecture binary_downloader "regctl" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
case "$(uname --machine)" in [[ -f "$ScriptWorkDir/regctl" ]] && regbin="$ScriptWorkDir/regctl"
x86_64|amd64) architecture="amd64" ;; else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
arm64|aarch64) architecture="arm64";;
*) echo "Architecture not supported, exiting." ; exit 1;;
esac
RegUrl="https://github.com/regclient/regclient/releases/latest/download/regctl-linux-$architecture"
if [[ $(command -v curl) ]]; then curl -L $RegUrl > "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
elif [[ $(command -v wget) ]]; then wget $RegUrl -O "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
else
printf "%s\n" "curl/wget not available - get regctl manually from the repo link, quitting."
fi
else
printf "%s\n" "Dependency missing, quitting."
exit 1
fi fi
fi fi
# Final check if binary is correct # Final check if binary is correct
@@ -210,12 +247,6 @@ else
exit 1 exit 1
fi fi
# Check for jq binary
if [[ ! $(command -v jq) ]] ; then
printf "%s\n" "No jq binary, please install jq and try again, exiting."
exit 1
fi
# Numbered List function # Numbered List function
options() { options() {
num=1 num=1
@@ -253,8 +284,9 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
progress_bar "$RegCheckQue" "$ContCount" progress_bar "$RegCheckQue" "$ContCount"
# 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
ImageId=$(docker inspect "$i" --format='{{.Image}}')
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 "$ImageId" --format '{{.RepoDigests}}')
# Checking for errors while setting the variable # Checking for errors while setting the variable
if RegHash=$(${t_out} $regbin -v error image digest --list "$RepoUrl" 2>&1) ; then if RegHash=$(${t_out} $regbin -v error image digest --list "$RepoUrl" 2>&1) ; then
if [[ "$LocalHash" = *"$RegHash"* ]] ; then if [[ "$LocalHash" = *"$RegHash"* ]] ; then
@@ -315,17 +347,17 @@ if [ -n "$GotUpdates" ] ; then
# Extract labels and metadata # Extract labels and metadata
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}') ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}') ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
ContPath=$(jq -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels") ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
[ "$ContPath" == "null" ] && ContPath="" [ "$ContPath" == "null" ] && ContPath=""
ContConfigFile=$(jq -r '."com.docker.compose.project.config_files"' <<< "$ContLabels") ContConfigFile=$($jqbin -r '."com.docker.compose.project.config_files"' <<< "$ContLabels")
[ "$ContConfigFile" == "null" ] && ContConfigFile="" [ "$ContConfigFile" == "null" ] && ContConfigFile=""
ContName=$(jq -r '."com.docker.compose.service"' <<< "$ContLabels") ContName=$($jqbin -r '."com.docker.compose.service"' <<< "$ContLabels")
[ "$ContName" == "null" ] && ContName="" [ "$ContName" == "null" ] && ContName=""
ContEnv=$(jq -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels") ContEnv=$($jqbin -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels")
[ "$ContEnv" == "null" ] && ContEnv="" [ "$ContEnv" == "null" ] && ContEnv=""
ContUpdateLabel=$(jq -r '."mag37.dockcheck.update"' <<< "$ContLabels") ContUpdateLabel=$($jqbin -r '."mag37.dockcheck.update"' <<< "$ContLabels")
[ "$ContUpdateLabel" == "null" ] && ContUpdateLabel="" [ "$ContUpdateLabel" == "null" ] && ContUpdateLabel=""
ContRestartStack=$(jq -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels") ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
[ "$ContRestartStack" == "null" ] && ContRestartStack="" [ "$ContRestartStack" == "null" ] && ContRestartStack=""
# Checking if compose-values are empty - hence started with docker run # Checking if compose-values are empty - hence started with docker run

View File

@@ -49,4 +49,6 @@ Content-Transfer-Encoding: 7bit
$MessageBody $MessageBody
From $SenderName From $SenderName
__EOF __EOF
# This ensures DSM's container manager will also see the update
/var/packages/ContainerManager/target/tool/image_upgradable_checker
} }

View File

@@ -14,7 +14,7 @@ send_notification() {
# Setting the MessageTitle and MessageBody variable here. # Setting the MessageTitle and MessageBody variable here.
MessageTitle="${FromHost} - updates available." MessageTitle="${FromHost} - updates available."
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString" printf -v MessageBody "Containers on $FromHost with updates available:\n$UpdToString"
# Modify to fit your setup: # Modify to fit your setup:
GotifyToken="Your Gotify token here" GotifyToken="Your Gotify token here"
@@ -24,6 +24,6 @@ send_notification() {
-F "title=${MessageTitle}" \ -F "title=${MessageTitle}" \
-F "message=${MessageBody}" \ -F "message=${MessageBody}" \
-F "priority=5" \ -F "priority=5" \
-X POST "${GotifyUrl}" &> /dev/null -X POST "${GotifyUrl}" 1> /dev/null
} }