diff --git a/README.md b/README.md index 618eb89..46d332a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ ___ ## :bell: Changelog +- **v0.5.8.0**: Added version checks to all templates and a notification if a new template is released. - **v0.5.7.0**: Rewritten templates - now with a function to notify when there's a new Dockcheck release. - Manually migrate your current `notify.sh` settings to a new template for new functionality. - **v0.5.6.1**: Async xargs hotfix - due to errors `failed to request manifest head ... context canceled` @@ -29,9 +30,6 @@ ___ - To disable xargs `-P` flag (max processes) all together, set `MaxAsync` to 0. - **v0.5.6.0**: Heavily improved performance due to async checking for updates. - **v0.5.5.0**: osx and bsd compatibility changes + rewrite of dependency installer -- **v0.5.4.0**: Added support for a Prometheus+node_exporter metric collection through a file collector. -- **v0.5.3.0**: 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. ___ @@ -113,7 +111,7 @@ Add preferred `notify.sh`-template to the same directory - this will not be touc ## :loudspeaker: Notifications Trigger with the `-i` flag. Run it scheduled with `-ni` to only get notified when there's updates available! -Will also send a notification when `dockcheck.sh` itself has an update. +Will also send a notification when `dockcheck.sh` itself has an update. Use a `notify_X.sh` template file from the **notify_templates** directory, copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh is added to .gitignore) **Current templates:** @@ -147,7 +145,7 @@ nginx -> https://github.com/docker-library/official-images/blob/master/library The `urls.list` file is just an example and I'd gladly see that people contribute back when they add their preferred URLs to their lists. ## :fast_forward: Asyncronous update checks with **xargs**; `-x N` option. (default=1) -Pass `-x N` where N is number of subprocesses allowed, experiment in your environment to find a suitable max! +Pass `-x N` where N is number of subprocesses allowed, experiment in your environment to find a suitable max! Change the default value by editing the `MaxAsync=N` variable in `dockcheck.sh`. To disable the subprocess function set `MaxAsync=0`. diff --git a/dockcheck.sh b/dockcheck.sh index b717dd0..e060a89 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="v0.5.7.0" -### ChangeNotes: Rewritten templates - now with a function to notify when theres a new Dockcheck release. +VERSION="v0.5.8.0" +### ChangeNotes: Added version checks to all templates and a notification if a new template is released. Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" @@ -292,7 +292,7 @@ fi check_image() { i="$1" local Excludes=($Excludes_string) - for e in "${Excludes[@]}" ; do + for e in "${Excludes[@]}" ; do if [[ "$i" == "$e" ]]; then echo Skip $i return @@ -326,7 +326,7 @@ export -f check_image datecheck export Excludes_string="${Excludes[@]}" # Can only export scalar variables 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 if (echo "test" | xargs -P 2 >/dev/null 2>&1) && [[ "$MaxAsync" != 0 ]]; then XargsAsync="-P $MaxAsync" else @@ -457,4 +457,3 @@ else fi exit 0 - diff --git a/notify_templates/notify_DSM.sh b/notify_templates/notify_DSM.sh index 7d38236..ddbc2c6 100644 --- a/notify_templates/notify_DSM.sh +++ b/notify_templates/notify_DSM.sh @@ -1,5 +1,6 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. -# INFO: ssmtp is depcerated - consider to use msmtp instead. +NOTIFY_DSM_VERSION="v0.1" +# INFO: ssmtp is deprecated - consider to use msmtp instead. # # Copy/rename this file to notify.sh to enable the notification snipppet. # mSMTP/sSMTP has to be installed and configured manually. @@ -70,5 +71,12 @@ dockcheck_notification() { # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1\nLatest version: $2\n\nChangenotes: $3\n" + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_DSM.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_DSM_VERSION/s/NOTIFY_DSM_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_DSM_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_DSM.sh update avialable:\n $NOTIFY_DSM_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_apprise.sh b/notify_templates/notify_apprise.sh index a687eb9..fef4303 100644 --- a/notify_templates/notify_apprise.sh +++ b/notify_templates/notify_apprise.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_APPRISE_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -38,10 +39,17 @@ send_notification() { ### to not send notifications when dockcheck itself has updates. dockcheck_notification() { printf "\nSending Apprise dockcheck notification\n" - + MessageTitle="$FromHost - New version of dockcheck available." # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" - + + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_apprise.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_APPRISE_VERSION/s/NOTIFY_APPRISE_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_APPRISE_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_apprise.sh update avialable:\n $NOTIFY_APPRISE_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_discord.sh b/notify_templates/notify_discord.sh index 2f7f913..5728f74 100644 --- a/notify_templates/notify_discord.sh +++ b/notify_templates/notify_discord.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_DISCORD_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -31,5 +32,12 @@ dockcheck_notification() { printf "\nSending Discord dockcheck notification\n" MessageBody="$FromHost - New version of dockcheck available: \n Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_discord.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_DISCORD_VERSION/s/NOTIFY_DISCORD_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_DISCORD_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_discord.sh update avialable:\n $NOTIFY_DISCORD_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_generic.sh b/notify_templates/notify_generic.sh index b93c2b2..700e84a 100644 --- a/notify_templates/notify_generic.sh +++ b/notify_templates/notify_generic.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_GENERIC_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # generic sample, the "Hello World" of notification addons @@ -14,12 +15,12 @@ trigger_notification() { send_notification() { [ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") UpdToString=$( printf '%s\\n' "${Updates[@]}" ) - + # platform specific notification code would go here printf "\n%bGeneric notification addon:%b" "$c_green" "$c_reset" MessageTitle="$FromHost - updates available." printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString" - + trigger_notification } @@ -27,10 +28,17 @@ send_notification() { ### to not send notifications when dockcheck itself has updates. dockcheck_notification() { printf "\nGeneric dockcheck notification\n" - + MessageTitle="$FromHost - New version of dockcheck available." # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" - + + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_generic.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_GENERIC_VERSION/s/NOTIFY_GENERIC_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_GENERIC_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_generic.sh update avialable:\n $NOTIFY_GENERIC_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_gotify.sh b/notify_templates/notify_gotify.sh index d5eae60..3cb4d3e 100644 --- a/notify_templates/notify_gotify.sh +++ b/notify_templates/notify_gotify.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_GOTIFY_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -41,5 +42,12 @@ dockcheck_notification() { # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_gotify.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_GOTIFY_VERSION/s/NOTIFY_GOTIFY_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_GOTIFY_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_gotify.sh update avialable:\n $NOTIFY_GOTIFY_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_matrix.sh b/notify_templates/notify_matrix.sh index 9279a42..686a4b1 100644 --- a/notify_templates/notify_matrix.sh +++ b/notify_templates/notify_matrix.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_MATRIX_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -34,10 +35,17 @@ send_notification() { ### to not send notifications when dockcheck itself has updates. dockcheck_notification() { printf "\nSending Matrix dockcheck notification\n" - + MessageTitle="$FromHost - New version of dockcheck available." # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" - + + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_matrix.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_MATRIX_VERSION/s/NOTIFY_MATRIX_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_MATRIX_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_matrix.sh update avialable:\n $NOTIFY_MATRIX_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_ntfy-sh.sh b/notify_templates/notify_ntfy-sh.sh index 68b293b..dc6d24f 100644 --- a/notify_templates/notify_ntfy-sh.sh +++ b/notify_templates/notify_ntfy-sh.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_NTFYSH_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Setup app and subscription at https://ntfy.sh @@ -33,10 +34,17 @@ send_notification() { ### to not send notifications when dockcheck itself has updates. dockcheck_notification() { printf "\nSending ntfy.sh dockcheck notification\n" - + MessageTitle="$FromHost - New version of dockcheck available." # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" - + + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_ntfy-sh.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_NTFYSH_VERSION/s/NOTIFY_NTFYSH_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_NTFYSH_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_ntfy-sh.sh update avialable:\n $NOTIFY_NTFYSH_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_pushbullet.sh b/notify_templates/notify_pushbullet.sh index 7429e03..0df62cb 100644 --- a/notify_templates/notify_pushbullet.sh +++ b/notify_templates/notify_pushbullet.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_PUSHBULLET_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -39,5 +40,12 @@ dockcheck_notification() { # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_pushbullet.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_PUSHBULLET_VERSION/s/NOTIFY_PUSHBULLET_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_PUSHBULLET_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_pushbullet.sh update avialable:\n $NOTIFY_PUSHBULLET_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_pushover.sh b/notify_templates/notify_pushover.sh index 69e951f..dc28493 100644 --- a/notify_templates/notify_pushover.sh +++ b/notify_templates/notify_pushover.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_PUSHOVER_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -40,10 +41,17 @@ send_notification() { ### to not send notifications when dockcheck itself has updates. dockcheck_notification() { printf "\nSending pushover dockcheck notification\n" - + MessageTitle="$FromHost - New version of dockcheck available." # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" - + + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_pushover.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_PUSHOVER_VERSION/s/NOTIFY_PUSHOVER_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_PUSHOVER_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_pushover.sh update avialable:\n $NOTIFY_PUSHOVER_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_smtp.sh b/notify_templates/notify_smtp.sh index 551e434..55e325b 100644 --- a/notify_templates/notify_smtp.sh +++ b/notify_templates/notify_smtp.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_SMTP_VERSION="v0.1" # INFO: ssmtp is depcerated - consider to use msmtp instead. # # Copy/rename this file to notify.sh to enable the notification snipppet. @@ -59,5 +60,12 @@ dockcheck_notification() { # Setting the MessageBody variable here. printf -v MessageBody "Installed version: $1 \nLatest version: $2 \n\nChangenotes: $3" + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_smtp.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_SMTP_VERSION/s/NOTIFY_SMTP_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_SMTP_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_smtp.sh update avialable:\n $NOTIFY_SMTP_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification } diff --git a/notify_templates/notify_telegram.sh b/notify_templates/notify_telegram.sh index e8bd8df..5113f35 100644 --- a/notify_templates/notify_telegram.sh +++ b/notify_templates/notify_telegram.sh @@ -1,4 +1,5 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +NOTIFY_TELEGRAM_VERSION="v0.1" # # Copy/rename this file to notify.sh to enable the notification snippet. # Required receiving services must already be set up. @@ -34,10 +35,17 @@ send_notification() { ### to not send notifications when dockcheck itself has updates. dockcheck_notification() { printf "\nSending Telegram dockcheck notification\n" - + MessageTitle="$FromHost - New version of dockcheck available." # Setting the MessageBody variable here. printf -v MessageBody "$FromHost - New version of dockcheck available.\n\nInstalled version: $1 \nLatest version: $2 \n\nChangenotes: $3" - + + RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_telegram.sh" + LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_TELEGRAM_VERSION/s/NOTIFY_TELEGRAM_VERSION=//p" | tr -d '"')" + if [[ "$NOTIFY_TELEGRAM_VERSION" != "$LatestNotifyRelease" ]] ; then + printf -v NotifyUpdate "\n\nnotify_telegram.sh update avialable:\n $NOTIFY_TELEGRAM_VERSION -> $LatestNotifyRelease\n" + MessageBody="${MessageBody}${NotifyUpdate}" + fi + trigger_notification }