From 67648efbe87467e94e1dfe785ec5883b4953f5bb Mon Sep 17 00:00:00 2001
From: Christopher Berg
Date: Sat, 31 May 2025 21:55:21 +0200
Subject: [PATCH 01/41] ntfy notification bug fixes (#197)
---
default.config | 2 +-
notify_templates/{notify_ntfy-sh.sh => notify_ntfy.sh} | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
rename notify_templates/{notify_ntfy-sh.sh => notify_ntfy.sh} (81%)
diff --git a/default.config b/default.config
index cd26f57..0e590c2 100644
--- a/default.config
+++ b/default.config
@@ -28,7 +28,7 @@
## All commented values are examples only. Modify as needed.
##
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
-# NOTIFY_CHANNELS="apprise discord DSM generic gotify matrix ntfy-sh pushbullet pushover slack smtp telegram"
+# NOTIFY_CHANNELS="apprise discord DSM generic gotify matrix ntfy pushbullet pushover slack smtp telegram"
#
## Uncomment to not send notifications when dockcheck itself has updates.
# DISABLE_DOCKCHECK_NOTIFICATION=false
diff --git a/notify_templates/notify_ntfy-sh.sh b/notify_templates/notify_ntfy.sh
similarity index 81%
rename from notify_templates/notify_ntfy-sh.sh
rename to notify_templates/notify_ntfy.sh
index 5a189c5..b977d6d 100644
--- a/notify_templates/notify_ntfy-sh.sh
+++ b/notify_templates/notify_ntfy.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_NTFYSH_VERSION="v0.4"
+NOTIFY_NTFY_VERSION="v0.4"
#
# Setup app and subscription at https://ntfy.sh
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -7,12 +7,12 @@ NOTIFY_NTFYSH_VERSION="v0.4"
# Do not modify this file directly within the "notify_templates" subdirectory. Set NTFY_DOMAIN and NTFY_TOPIC_NAME in your dockcheck.config file.
if [[ -z "${NTFY_DOMAIN:-}" ]] || [[ -z "${NTFY_TOPIC_NAME:-}" ]]; then
- printf "Ntfy.sh notification channel enabled, but required configuration variables are missing. Ntfy.sh notifications will not be sent.\n"
+ printf "Ntfy notification channel enabled, but required configuration variables are missing. Ntfy notifications will not be sent.\n"
- remove_channel ntfy-sh
+ remove_channel ntfy
fi
-trigger_ntfy-sh_notification() {
+trigger_ntfy_notification() {
NtfyUrl="${NTFY_DOMAIN}/${NTFY_TOPIC_NAME}"
# e.g.
# NTFY_DOMAIN=ntfy.sh
From 4a16d2f1eaa0498ed24a7bf5abba49bba4a5d348 Mon Sep 17 00:00:00 2001
From: mag37
Date: Sat, 31 May 2025 22:02:52 +0200
Subject: [PATCH 02/41] -r clarification
Clarified the help message for the -r option.
---
dockcheck.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dockcheck.sh b/dockcheck.sh
index 992a267..45e03cc 100755
--- a/dockcheck.sh
+++ b/dockcheck.sh
@@ -49,7 +49,7 @@ Help() {
echo "-M Prints custom releasenote urls as markdown (requires template support)."
echo "-n No updates; only checking availability without interaction."
echo "-p Auto-prune dangling images after update."
- echo "-r Allow updating images for docker run; won't update the container."
+ echo "-r Allow checking for updates/updating images for docker run containers. Won't update the container."
echo "-s Include stopped containers in the check. (Logic: docker ps -a)."
echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default."
echo "-u Allow automatic self updates - caution as this will pull new code and autorun it."
From 272615166e4c4d6953f6a027a2736f406ee37195 Mon Sep 17 00:00:00 2001
From: mag37
Date: Sat, 31 May 2025 22:05:35 +0200
Subject: [PATCH 03/41] ntfy rename
Corrected all mentions of the ntfy template with its new name.
Also clarified the help message of the -r option.
---
README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index af2f45d..ce036c3 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ ___
- Sourcing templates from either project root or subdirectory
- Consistent newline handling
- Added (when using `-d`) days old message to notification title
- - Added ntfy.sh self hosted domain option to config
+ - Added ntfy self hosted domain option to config
- jq fixes to templates (and properly using $jqbin)
- **v0.6.5**: Refactored notification logic. See notify_templates/notify_v2.sh for upgrade steps.
- Added helper functions to simplify sourcing files and executing functions if they exist.
@@ -38,7 +38,7 @@ ___
- Added logic to skip update check on non-compose containers (unless `-r` option).
- Added option `-F` to revert to `compose up -d ` targeting specific container and not the stack.
- Also added corresponding label and config-option.
- - Added markdown formatting to `notify_ntfy-sh.sh` template.
+ - Added markdown formatting to `notify_ntfy.sh` template.
- **v0.6.3**: Some fixes and changes:
- Stops when a container recreation (compose up -d) fails, also `up`s the whole stack now.
- `-M`, Markdown format url-releasenotes in notification (requires template rework, look at gotify!)
@@ -70,7 +70,7 @@ Options:
-M Prints custom releasenote urls as markdown (requires template support).
-n No updates, only checking availability.
-p Auto-Prune dangling images after update.
--r Allow updating images for docker run, wont update the container.
+-r Allow checking for updates/updating images for docker run containers. Won't update the container.
-s Include stopped containers in the check. (Logic: docker ps -a).
-t N Set a timeout (in seconds) per container for registry checkups, 10 is default.
-u Allow automatic self updates - caution as this will pull new code and autorun it.
@@ -149,7 +149,7 @@ Make certain your project directory is laid out as below. You only need the noti
│ ├── notify_generic.sh
│ ├── notify_gotify.sh
│ ├── notify_matrix.sh
-│ ├── notify_ntfy-sh.sh
+│ ├── notify_ntfy.sh
│ ├── notify_pushbullet.sh
│ ├── notify_pushover.sh
│ ├── notify_slack.sh
@@ -176,7 +176,7 @@ copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh
- Apprise (with it's [multitude](https://github.com/caronc/apprise#supported-notifications) of notifications)
- both native [caronc/apprise](https://github.com/caronc/apprise) and the standalone [linuxserver/docker-apprise-api](https://github.com/linuxserver/docker-apprise-api)
- Read the [QuickStart](extras/apprise_quickstart.md)
-- [ntfy.sh](https://ntfy.sh/) - HTTP-based pub-sub notifications.
+- [ntfy](https://ntfy.sh/) - HTTP-based pub-sub notifications.
- [Gotify](https://gotify.net/) - a simple server for sending and receiving messages.
- [Pushbullet](https://www.pushbullet.com/) - connecting different devices with cross-platform features.
- [Telegram](https://telegram.org/) - Telegram chat API.
From a0e11de38354b1b0fa798d13ee64bcbb49e702c7 Mon Sep 17 00:00:00 2001
From: vorezal <37914382+vorezal@users.noreply.github.com>
Date: Tue, 24 Jun 2025 09:16:48 -0400
Subject: [PATCH 04/41] Snooze feature, curl, and consolidation (#200)
* Snooze feature, curl, and consolidation
* Added snooze feature to delay notifications
* Added configurable default curl arguments
* Consolidated and standardized notify template update notifications
* Added curl error handling
* Snooze comment fix
* Grep, curl args, and variable init adjustments
* Modified grep commands to make use of word boundaries in order to avoid matching on substrings
* Set CurlRetryDelay, CurlRetryCount, and CurlConnectTimeout as individual variables
* Used :- for variable initialization where assignment is redundant
* Update dockcheck.sh change notes and fix variable collision
* Remove unnecessary cat and clarify readme
* reformatting
---------
Co-authored-by: Matthew Oleksowicz
Co-authored-by: mag37
---
.gitignore | 2 +
README.md | 45 +++--
default.config | 6 +
dockcheck.sh | 76 ++++----
notify_templates/notify_DSM.sh | 7 +-
notify_templates/notify_apprise.sh | 12 +-
notify_templates/notify_discord.sh | 8 +-
notify_templates/notify_gotify.sh | 8 +-
notify_templates/notify_matrix.sh | 8 +-
notify_templates/notify_ntfy.sh | 8 +-
notify_templates/notify_pushbullet.sh | 8 +-
notify_templates/notify_pushover.sh | 8 +-
notify_templates/notify_slack.sh | 8 +-
notify_templates/notify_smtp.sh | 6 +-
notify_templates/notify_telegram.sh | 8 +-
notify_templates/notify_v2.sh | 250 +++++++++++++++++++++-----
16 files changed, 350 insertions(+), 118 deletions(-)
diff --git a/.gitignore b/.gitignore
index da6210f..e5a2ded 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@
/dockcheck.config
# ignore the auto-installed regctl
regctl
+# ignore snooze file
+snooze.list
diff --git a/README.md b/README.md
index ce036c3..751e7b2 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,11 @@
___
## :bell: Changelog
+- **v0.6.7**: Snooze feature, curl, and consolidation
+ - Added snooze feature to delay notifications
+ - Added configurable default curl arguments
+ - Consolidated and standardized notify template update notifications
+ - Added curl error handling
- **v0.6.6**: Notify_v2 bugfixes
- Clearer readme and error messages
- Sourcing templates from either project root or subdirectory
@@ -34,16 +39,6 @@ ___
- Added support for notification management via environment variables.
- Moved notification secrets to **dockcheck.config**.
- Added retries to wget/curl to not get empty responses when github is slow.
-- **v0.6.4**: Restructured the update process - first pulls all updates, then recreates all containers.
- - Added logic to skip update check on non-compose containers (unless `-r` option).
- - Added option `-F` to revert to `compose up -d ` targeting specific container and not the stack.
- - Also added corresponding label and config-option.
- - Added markdown formatting to `notify_ntfy.sh` template.
-- **v0.6.3**: Some fixes and changes:
- - Stops when a container recreation (compose up -d) fails, also `up`s the whole stack now.
- - `-M`, Markdown format url-releasenotes in notification (requires template rework, look at gotify!)
- - Added [addons/DSM/README.md](./addons/DSM/README.md) for more info Synology DSM info.
- - Permission checks - graceful exit if no docker permissions + checking if root for pkg-manager.
___
@@ -137,8 +132,7 @@ If `notify.sh` is present and configured, it will be used. Otherwise, `notify_v2
Will send a list of containers with updates available and a notification when `dockcheck.sh` itself has an update.
Run it scheduled with `-ni` to only get notified when there's updates available!
-V2 installation and configuration (tag v0.6.5 or later):
-Remove or rename `notify.sh` if previously configured using the legacy method.
+#### Installation and configuration:
Make certain your project directory is laid out as below. You only need the notify_v2.sh file and any notification templates you wish to enable, but there is no harm in having all of them present.
```
.
@@ -160,17 +154,30 @@ Make certain your project directory is laid out as below. You only need the noti
├── dockcheck.sh
└── urls.list # optional
```
-If you wish to customize `notify_v2.sh` or the notify templates yourself, you may copy them to your project root directory alongside the main dockcheck.sh script (where they will also be ignored by git).
Uncomment and set the NOTIFY_CHANNELS environment variable in `dockcheck.config` to a space separated string of your desired notification channels to enable.
-Uncomment and set the environment variables related to the enabled notification channels.
-It is recommended not to make changes directly to the `notify_X.sh` template files within the `notify_templates` subdirectory and instead use only environment variables defined in `dockcheck.config` using this method.
+Uncomment and set the environment variables related to the enabled notification channels.
+It is recommended to only edit the environmental variables in `dockcheck.config` and not make changes directly to the `notify_X.sh` template files within the `notify_templates` subdirectory.
+If you wish to customize the notify templates yourself, you may copy them to your project root directory alongside the main `dockcheck.sh` script (where they will also be ignored by git).
+Customizing `notify_v2.sh` is handled the same as customizing the templates, but it must be renamed to `notify.sh` within the `dockcheck.sh` root directory.
-Legacy installation and configuration:
+
+#### Legacy installation and configuration:
Use a previous version of a `notify_X.sh` template file (tag v0.6.4 or earlier) from the **notify_templates** directory,
copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh is added to .gitignore)
+#### Snooze feature:
+**Use case:** You wish to be notified of available updates in a timely manner, but do not require reminders after the initial notification with the same frequency.
+e.g. *Dockcheck is scheduled to run every hour. You will receive an update notification within an hour of availability.*
+**Snooze enabled:** you will not receive another notification about updates for this container for a configurable period of time.
+**Snooze disabled:** you will receive additional notifications every hour.
-**Current templates:**
+To enable snooze, uncomment the `SNOOZE_SECONDS` variable in your `dockcheck.config` file and set it to the number of seconds you wish to prevent duplicate alerts.
+The true snooze duration will be 60 seconds less than your configure value to account for minor scheduling or script run time issues.
+If an update becomes available for an item that is not snoozed, notifications will be sent and include all available updates for that item's category, even snoozed items.
+`dockcheck.sh` updates, notification template updates, and container updates are considered three separate categories.
+
+
+#### Current notify templates:
- Synology [DSM](https://www.synology.com/en-global/dsm)
- Email with [mSMTP](https://wiki.debian.org/msmtp) (or deprecated alternative [sSMTP](https://wiki.debian.org/sSMTP))
- Apprise (with it's [multitude](https://github.com/caronc/apprise#supported-notifications) of notifications)
@@ -185,7 +192,7 @@ copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh
- [Discord](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) - Discord webhooks.
- [Slack](https://api.slack.com/tutorials/tracks/posting-messages-with-curl) - Slack curl api
-Further additions are welcome - suggestions or PR!
+Further additions are welcome - suggestions or PRs!
Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2).
### :date: Release notes addon
@@ -228,7 +235,7 @@ See the [README.md](./addons/prometheus/README.md) for more detailed information
Contributed by [tdralle](https://github.com/tdralle).
### :small_orange_diamond: Zabbix config to monitor docker image updates
-If you already use Zabbix - this config will Shows number of available docker image updates on host.
+If you already use Zabbix - this config will show numbers of available docker image updates on host.
Example: *2 Docker Image updates on host-xyz*
See project: [thetorminal/zabbix-docker-image-updates](https://github.com/thetorminal/zabbix-docker-image-updates)
diff --git a/default.config b/default.config
index 0e590c2..2831591 100644
--- a/default.config
+++ b/default.config
@@ -23,6 +23,9 @@
#PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)`
#PrintMarkdownURL=true # Prints custom releasenote urls as markdown
#OnlySpecific=true # Only compose up the specific container, not the whole compose. (useful for master-compose structure).
+#CurlRetryDelay=1 # Time between curl retries
+#CurlRetryCount=3 # Max number of curl retries
+#CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing
### Notify settings
## All commented values are examples only. Modify as needed.
@@ -30,6 +33,9 @@
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
# NOTIFY_CHANNELS="apprise discord DSM generic gotify matrix ntfy pushbullet pushover slack smtp telegram"
#
+## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze
+# SNOOZE_SECONDS=86400
+#
## Uncomment to not send notifications when dockcheck itself has updates.
# DISABLE_DOCKCHECK_NOTIFICATION=false
## Uncomment to not send notifications when notify scripts themselves have updates.
diff --git a/dockcheck.sh b/dockcheck.sh
index 45e03cc..d341ce9 100755
--- a/dockcheck.sh
+++ b/dockcheck.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-VERSION="v0.6.6"
-# ChangeNotes: notify_v2 bugfixes - clarify readme and error messages, better sourcing templates, tweaks.
+VERSION="v0.6.7"
+# ChangeNotes: snooze feature (see readme), curl arguments, cleanup.
Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
@@ -13,10 +13,6 @@ ScriptArgs=( "$@" )
ScriptPath="$(readlink -f "$0")"
ScriptWorkDir="$(dirname "$ScriptPath")"
-# Check if there's a new release of the script
-LatestRelease="$(curl --retry 3 --retry-delay 1 --retry-max-time 10 -s -r 0-50 "$RawUrl" | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
-LatestChanges="$(curl --retry 3 --retry-delay 1 --retry-max-time 10 -s -r 0-200 "$RawUrl" | sed -n "/ChangeNotes/s/# ChangeNotes: //p")"
-
# Source helper functions
source_if_exists() {
if [[ -s "$1" ]]; then source "$1"; fi
@@ -60,31 +56,32 @@ Help() {
}
# Initialise variables
-Timeout=${Timeout:=10}
-MaxAsync=${MaxAsync:=1}
-BarWidth=${BarWidth:=50}
-AutoMode=${AutoMode:=false}
-DontUpdate=${DontUpdate:=false}
-AutoPrune=${AutoPrune:=false}
-AutoSelfUpdate=${AutoSelfUpdate:=false}
-OnlyLabel=${OnlyLabel:=false}
-Notify=${Notify:=false}
-ForceRestartStacks=${ForceRestartStacks:=false}
-DRunUp=${DRunUp:=false}
-MonoMode=${MonoMode:=false}
-PrintReleaseURL=${PrintReleaseURL:=false}
-PrintMarkdownURL=${PrintMarkdownURL:=false}
-Stopped=${Stopped:=""}
+Timeout=${Timeout:-10}
+MaxAsync=${MaxAsync:-1}
+BarWidth=${BarWidth:-50}
+AutoMode=${AutoMode:-false}
+DontUpdate=${DontUpdate:-false}
+AutoPrune=${AutoPrune:-false}
+AutoSelfUpdate=${AutoSelfUpdate:-false}
+OnlyLabel=${OnlyLabel:-false}
+Notify=${Notify:-false}
+ForceRestartStacks=${ForceRestartStacks:-false}
+DRunUp=${DRunUp:-false}
+MonoMode=${MonoMode:-false}
+PrintReleaseURL=${PrintReleaseURL:-false}
+PrintMarkdownURL=${PrintMarkdownURL:-false}
+Stopped=${Stopped:-""}
CollectorTextFileDirectory=${CollectorTextFileDirectory:-}
Exclude=${Exclude:-}
DaysOld=${DaysOld:-}
-OnlySpecific=${OnlySpecific:=false}
-SpecificContainer=${SpecificContainer:=""}
+OnlySpecific=${OnlySpecific:-false}
+SpecificContainer=${SpecificContainer:-""}
Excludes=()
GotUpdates=()
NoUpdates=()
GotErrors=()
SelectedUpdates=()
+CurlArgs="--retry ${CurlRetryCount:=3} --retry-delay ${CurlRetryDelay:=1} --connect-timeout ${CurlConnectTimeout:=5} -sf"
regbin=""
jqbin=""
@@ -125,6 +122,11 @@ shift "$((OPTIND-1))"
# Set $1 to a variable for name filtering later
SearchName="${1:-}"
+# Check if there's a new release of the script
+LatestSnippet="$(curl ${CurlArgs} -r 0-200 "$RawUrl" || printf "undefined")"
+LatestRelease="$(echo "${LatestSnippet}" | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
+LatestChanges="$(echo "${LatestSnippet}" | sed -n "/ChangeNotes/s/# ChangeNotes: //p")"
+
# Basic notify configuration check
if [[ "${Notify}" == true ]] && [[ ! -s "${ScriptWorkDir}/notify.sh" ]] && [[ -z "${NOTIFY_CHANNELS:-}" ]]; then
printf "Using v2 notifications with -i flag passed but no notify channels configured in dockcheck.config. This will result in no notifications being sent.\n"
@@ -166,7 +168,7 @@ exec_if_exists_or_fail() {
self_update_curl() {
cp "$ScriptPath" "$ScriptPath".bak
if command -v curl &>/dev/null; then
- curl --retry 3 --retry-delay 1 --retry-max-time 10 -L $RawUrl > "$ScriptPath"; chmod +x "$ScriptPath"
+ curl ${CurlArgs} -L $RawUrl > "$ScriptPath"; chmod +x "$ScriptPath" || { printf "ERROR: Failed to curl updated Dockcheck.sh script. Skipping update.\n"; return 1; }
printf "\n%b---%b starting over with the updated version %b---%b\n" "$c_yellow" "$c_teal" "$c_yellow" "$c_reset"
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
exit 1 # Exit the old instance
@@ -270,7 +272,7 @@ binary_downloader() {
*) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset"; exit 1;;
esac
GetUrl="${BinaryUrl/TEMP/"$architecture"}"
- if command -v curl &>/dev/null; then curl --retry 3 --retry-delay 1 --retry-max-time 10 -L "$GetUrl" > "$ScriptWorkDir/$BinaryName";
+ if command -v curl &>/dev/null; then curl ${CurlArgs} -L "$GetUrl" > "$ScriptWorkDir/$BinaryName" || { printf "ERROR: Failed to curl binary dependency. Rerun the script to retry.\n"; exit 1; }
elif command -v wget &>/dev/null; then wget --waitretry=1 --timeout=15 -t 10 "$GetUrl" -O "$ScriptWorkDir/$BinaryName";
else printf "\n%bcurl/wget not available - get %s manually from the repo link, exiting.%b" "$c_red" "$BinaryName" "$c_reset"; exit 1;
fi
@@ -346,15 +348,19 @@ list_options() {
}
# Version check & initiate self update
-if [[ "$VERSION" != "$LatestRelease" ]]; then
- printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges"
- if [[ "$AutoMode" == false ]]; then
- read -r -p "Would you like to update? y/[n]: " SelfUpdate
- [[ "$SelfUpdate" =~ [yY] ]] && self_update
- elif [[ "$AutoMode" == true ]] && [[ "$AutoSelfUpdate" == true ]]; then self_update;
- else
- [[ "$Notify" == true ]] && { exec_if_exists_or_fail dockcheck_notification "$VERSION" "$LatestRelease" "$LatestChanges" || printf "Could not source notification function.\n"; }
+if [[ "$LatestRelease" != "undefined" ]]; then
+ if [[ "$VERSION" != "$LatestRelease" ]]; then
+ printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges"
+ if [[ "$AutoMode" == false ]]; then
+ read -r -p "Would you like to update? y/[n]: " SelfUpdate
+ [[ "$SelfUpdate" =~ [yY] ]] && self_update
+ elif [[ "$AutoMode" == true ]] && [[ "$AutoSelfUpdate" == true ]]; then self_update;
+ else
+ [[ "$Notify" == true ]] && { exec_if_exists_or_fail dockcheck_notification "$VERSION" "$LatestRelease" "$LatestChanges" || printf "Could not source notification function.\n"; }
+ fi
fi
+else
+ printf "ERROR: Failed to curl latest Dockcheck.sh release version.\n"
fi
# Version check for notify templates
@@ -420,7 +426,7 @@ check_image() {
# Checking for errors while setting the variable
if RegHash=$($t_out "$regbin" -v error image digest --list "$RepoUrl" 2>&1); then
- if [[ "$LocalHash" = *"$RegHash"* ]]; then
+ if [[ "$LocalHash" == *"$RegHash"* ]]; then
printf "%s\n" "NoUpdates $i"
else
if [[ -n "${DaysOld:-}" ]] && ! datecheck; then
@@ -568,7 +574,7 @@ if [[ -n "${GotUpdates:-}" ]]; then
# cd to the compose-file directory to account for people who use relative volumes
cd "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; }
## Reformatting path + multi compose
- if [[ $ContConfigFile = '/'* ]]; then
+ if [[ $ContConfigFile == '/'* ]]; then
CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s " "$conf"; done)
else
CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s/%s " "$ContPath" "$conf"; done)
diff --git a/notify_templates/notify_DSM.sh b/notify_templates/notify_DSM.sh
index edfb51f..08d85c1 100644
--- a/notify_templates/notify_DSM.sh
+++ b/notify_templates/notify_DSM.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_DSM_VERSION="v0.2"
+NOTIFY_DSM_VERSION="v0.3"
# INFO: ssmtp is deprecated - consider to use msmtp instead.
#
# mSMTP/sSMTP has to be installed and configured manually.
@@ -45,6 +45,11 @@ Content-Transfer-Encoding: 7bit
$MessageBody
From $SenderName
__EOF
+
+if [[ $? -gt 0 ]]; then
+ NotifyError=true
+fi
+
# This ensures DSM's container manager will also see the update
/var/packages/ContainerManager/target/tool/image_upgradable_checker
}
diff --git a/notify_templates/notify_apprise.sh b/notify_templates/notify_apprise.sh
index 4da3d71..1fa94de 100644
--- a/notify_templates/notify_apprise.sh
+++ b/notify_templates/notify_apprise.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_APPRISE_VERSION="v0.2"
+NOTIFY_APPRISE_VERSION="v0.3"
#
# Required receiving services must already be set up.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -18,6 +18,10 @@ trigger_apprise_notification() {
if [[ -n "${APPRISE_PAYLOAD:-}" ]]; then
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
${APPRISE_PAYLOAD}
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
fi
# e.g. APPRISE_PAYLOAD='mailto://myemail:mypass@gmail.com
@@ -27,6 +31,10 @@ trigger_apprise_notification() {
if [[ -n "${APPRISE_URL:-}" ]]; then
AppriseURL="${APPRISE_URL}"
- curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL # e.g. APPRISE_URL=http://apprise.mydomain.tld:1234/notify/apprise
+ curl -S -o /dev/null ${CurlArgs} -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL # e.g. APPRISE_URL=http://apprise.mydomain.tld:1234/notify/apprise
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
fi
}
\ No newline at end of file
diff --git a/notify_templates/notify_discord.sh b/notify_templates/notify_discord.sh
index 97bf1fa..fa1a32d 100644
--- a/notify_templates/notify_discord.sh
+++ b/notify_templates/notify_discord.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_DISCORD_VERSION="v0.3"
+NOTIFY_DISCORD_VERSION="v0.4"
#
# Required receiving services must already be set up.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -20,5 +20,9 @@ trigger_discord_notification() {
--arg body "$MessageBody" \
'{"username": $username, "content": $body}' )
- curl -sS -o /dev/null --fail -X POST -H "Content-Type: application/json" -d "$JsonData" "$DiscordWebhookUrl"
+ curl -S -o /dev/null ${CurlArgs} -X POST -H "Content-Type: application/json" -d "$JsonData" "$DiscordWebhookUrl"
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
diff --git a/notify_templates/notify_gotify.sh b/notify_templates/notify_gotify.sh
index 4e373d6..d3d2c67 100644
--- a/notify_templates/notify_gotify.sh
+++ b/notify_templates/notify_gotify.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_GOTIFY_VERSION="v0.3"
+NOTIFY_GOTIFY_VERSION="v0.4"
#
# Required receiving services must already be set up.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -28,5 +28,9 @@ trigger_gotify_notification() {
--arg type "$ContentType" \
'{message: $body, title: $title, priority: 5, extras: {"client::display": {"contentType": $type}}}' )
- curl -s -S --data "${JsonData}" -H 'Content-Type: application/json' -X POST "${GotifyUrl}" 1> /dev/null
+ curl -S -o /dev/null ${CurlArgs} --data "${JsonData}" -H 'Content-Type: application/json' -X POST "${GotifyUrl}" 1> /dev/null
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
diff --git a/notify_templates/notify_matrix.sh b/notify_templates/notify_matrix.sh
index 8cf20b5..bcff5d2 100644
--- a/notify_templates/notify_matrix.sh
+++ b/notify_templates/notify_matrix.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_MATRIX_VERSION="v0.2"
+NOTIFY_MATRIX_VERSION="v0.3"
#
# Required receiving services must already be set up.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -19,5 +19,9 @@ trigger_matrix_notification() {
MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}"
# URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx
- curl -sS -o /dev/null --fail -X POST "$MatrixServer/_matrix/client/r0/rooms/$Room_id/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody"
+ curl -S -o /dev/null ${CurlArgs} -X POST "$MatrixServer/_matrix/client/r0/rooms/$Room_id/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody"
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
\ No newline at end of file
diff --git a/notify_templates/notify_ntfy.sh b/notify_templates/notify_ntfy.sh
index b977d6d..d413a2c 100644
--- a/notify_templates/notify_ntfy.sh
+++ b/notify_templates/notify_ntfy.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_NTFY_VERSION="v0.4"
+NOTIFY_NTFYSH_VERSION="v0.5"
#
# Setup app and subscription at https://ntfy.sh
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -24,9 +24,13 @@ trigger_ntfy_notification() {
ContentType="Markdown: no" #text/plain
fi
- curl -sS -o /dev/null --show-error --fail \
+ curl -S -o /dev/null ${CurlArgs} \
-H "Title: $MessageTitle" \
-H "$ContentType" \
-d "$MessageBody" \
"$NtfyUrl"
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
diff --git a/notify_templates/notify_pushbullet.sh b/notify_templates/notify_pushbullet.sh
index 182c78d..78dec0b 100644
--- a/notify_templates/notify_pushbullet.sh
+++ b/notify_templates/notify_pushbullet.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_PUSHBULLET_VERSION="v0.2"
+NOTIFY_PUSHBULLET_VERSION="v0.3"
#
# Required receiving services must already be set up.
# Requires jq installed and in PATH.
@@ -18,5 +18,9 @@ trigger_pushbullet_notification() {
PushToken="${PUSHBULLET_TOKEN}" # e.g. PUSHBULLET_TOKEN=token-value
# Requires jq to process json data
- "$jqbin" -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -sS -o /dev/null --show-error --fail -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @-
+ "$jqbin" -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -S -o /dev/null ${CurlArgs} -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @-
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
diff --git a/notify_templates/notify_pushover.sh b/notify_templates/notify_pushover.sh
index 2f8bdda..60ffad6 100644
--- a/notify_templates/notify_pushover.sh
+++ b/notify_templates/notify_pushover.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_PUSHOVER_VERSION="v0.2"
+NOTIFY_PUSHOVER_VERSION="v0.3"
#
# Required receiving services must already be set up.
# Requires jq installed and in PATH.
@@ -19,10 +19,14 @@ trigger_pushover_notification() {
PushoverToken="${PUSHOVER_TOKEN}" # e.g. PUSHOVER_TOKEN=token-value
# Sending the notification via Pushover
- curl -sS -o /dev/null --show-error --fail -X POST \
+ curl -S -o /dev/null ${CurlArgs} -X POST \
-F "token=$PushoverToken" \
-F "user=$PushoverUserKey" \
-F "title=$MessageTitle" \
-F "message=$MessageBody" \
$PushoverUrl
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
\ No newline at end of file
diff --git a/notify_templates/notify_slack.sh b/notify_templates/notify_slack.sh
index a760f3d..0a9cd7a 100644
--- a/notify_templates/notify_slack.sh
+++ b/notify_templates/notify_slack.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_SLACK_VERSION="v0.2"
+NOTIFY_SLACK_VERSION="v0.3"
#
# Setup app and token at https://api.slack.com/tutorials/tracks/posting-messages-with-curl
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -17,8 +17,12 @@ trigger_slack_notification() {
ChannelID="${SLACK_CHANNEL_ID}" # e.g. CHANNEL_ID=mychannel
SlackUrl="https://slack.com/api/chat.postMessage"
- curl -sS -o /dev/null --show-error --fail \
+ curl -S -o /dev/null ${CurlArgs} \
-d "text=$MessageBody" -d "channel=$ChannelID" \
-H "Authorization: Bearer $AccessToken" \
-X POST $SlackUrl
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
diff --git a/notify_templates/notify_smtp.sh b/notify_templates/notify_smtp.sh
index 2889475..f07588c 100644
--- a/notify_templates/notify_smtp.sh
+++ b/notify_templates/notify_smtp.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_SMTP_VERSION="v0.2"
+NOTIFY_SMTP_VERSION="v0.3"
# INFO: ssmtp is depcerated - consider to use msmtp instead.
#
# mSMTP/sSMTP has to be installed and configured manually.
@@ -40,4 +40,8 @@ Content-Transfer-Encoding: 7bit
$MessageBody
__EOF
+
+if [[ $? -gt 0 ]]; then
+ NotifyError=true
+fi
}
diff --git a/notify_templates/notify_telegram.sh b/notify_templates/notify_telegram.sh
index d254490..4f114eb 100644
--- a/notify_templates/notify_telegram.sh
+++ b/notify_templates/notify_telegram.sh
@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
-NOTIFY_TELEGRAM_VERSION="v0.3"
+NOTIFY_TELEGRAM_VERSION="v0.4"
#
# Required receiving services must already be set up.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -31,5 +31,9 @@ trigger_telegram_notification() {
--arg parse_mode "$ParseMode" \
'{"chat_id": $chatid, "text": $text, "message_thread_id": $thread, "disable_notification": false, "parse_mode": $parse_mode, "disable_web_page_preview": true}' )
- curl -sS -o /dev/null --fail -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$JsonData"
+ curl -S -o /dev/null ${CurlArgs} -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$JsonData"
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
}
diff --git a/notify_templates/notify_v2.sh b/notify_templates/notify_v2.sh
index 5990e1a..a34acfa 100644
--- a/notify_templates/notify_v2.sh
+++ b/notify_templates/notify_v2.sh
@@ -1,17 +1,28 @@
-NOTIFY_V2_VERSION="v0.2"
+NOTIFY_V2_VERSION="v0.3"
#
# If migrating from an older notify template, remove your existing notify.sh file.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
-# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script.
+# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script and rename to notify.sh.
# Enable and configure all required notification variables in your dockcheck.config file, e.g.:
# NOTIFY_CHANNELS=apprise gotify slack
# SLACK_TOKEN=xoxb-some-token-value
# GOTIFY_TOKEN=some.token
+# Number of seconds to snooze identical update notifications based on local image name
+# or dockcheck.sh/notify.sh template file updates.
+# Actual snooze will be 60 seconds less to avoid the chance of missed notifications due to minor scheduling or script run time issues.
+snooze="${SNOOZE_SECONDS:-}"
+SnoozeFile="${ScriptWorkDir}/snooze.list"
+
enabled_notify_channels=( ${NOTIFY_CHANNELS:-} )
FromHost=$(cat /etc/hostname)
+CurrentEpochTime=$(date +"%Y-%m-%dT%H:%M:%S")
+CurrentEpochSeconds=$(date +%s)
+
+NotifyError=false
+
remove_channel() {
local temp_array=()
for channel in "${enabled_notify_channels[@]}"; do
@@ -26,71 +37,222 @@ for channel in "${enabled_notify_channels[@]}"; do
printf "The notification channel ${channel} is enabled, but notify_${channel}.sh was not found. Check the ${ScriptWorkDir} directory or the notify_templates subdirectory.\n"
done
+notify_containers_count() {
+ unset NotifyContainers
+ NotifyContainers=()
+
+ [[ ! -f "${SnoozeFile}" ]] && touch "${SnoozeFile}"
+
+ for update in "$@"
+ do
+ read -a container <<< "${update}"
+ found=$(grep -w "${container[0]}" "${SnoozeFile}" || printf "")
+
+ if [[ -n "${found}" ]]; then
+ read -a arr <<< "${found}"
+ CheckEpochSeconds=$(( $(date -d "${arr[1]}" +%s 2>/dev/null) + ${snooze} - 60 )) || CheckEpochSeconds=$(( $(date -f "%Y-%m-%d" -j "${arr[1]}" +%s) + ${snooze} - 60 ))
+ if [[ "${CurrentEpochSeconds}" -gt "${CheckEpochSeconds}" ]]; then
+ NotifyContainers+=("${update}")
+ fi
+ else
+ NotifyContainers+=("${update}")
+ fi
+ done
+
+ printf "${#NotifyContainers[@]}"
+}
+
+update_snooze() {
+
+ [[ ! -f "${SnoozeFile}" ]] && touch "${SnoozeFile}"
+
+ for arg in "$@"
+ do
+ read -a entry <<< "${arg}"
+ found=$(grep -w "${entry[0]}" "${SnoozeFile}" || printf "")
+
+ if [[ -n "${found}" ]]; then
+ sed -e "s/${entry[0]}.*/${entry[0]} ${CurrentEpochTime}/" "${SnoozeFile}" > "${SnoozeFile}.new"
+ mv "${SnoozeFile}.new" "${SnoozeFile}"
+ else
+ printf "${entry[0]} ${CurrentEpochTime}\n" >> "${SnoozeFile}"
+ fi
+ done
+}
+
+cleanup_snooze() {
+ unset NotifyEntries
+ NotifyEntries=()
+ switch=""
+
+ [[ ! -f "${SnoozeFile}" ]] && touch "${SnoozeFile}"
+
+ for arg in "$@"
+ do
+ read -a entry <<< "${arg}"
+ NotifyEntries+=("${entry[0]}")
+ done
+
+ if [[ ! "${NotifyEntries[@]}" == *".sh"* ]]; then
+ switch="-v"
+ fi
+
+ while read -r entry datestamp; do
+ if [[ ! "${NotifyEntries[@]}" == *"$entry"* ]]; then
+ sed -e "/${entry}/d" "${SnoozeFile}" > "${SnoozeFile}.new"
+ mv "${SnoozeFile}.new" "${SnoozeFile}"
+ fi
+ done <<< "$(grep ${switch} '\.sh ' ${SnoozeFile})"
+}
+
send_notification() {
[[ -s "$ScriptWorkDir"/urls.list ]] && releasenotes || Updates=("$@")
- UpdToString=$( printf '%s\\n' "${Updates[@]}" )
- UpdToString=${UpdToString%\\n}
- for channel in "${enabled_notify_channels[@]}"; do
- printf "\nSending ${channel} notification\n"
+ if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
+ UpdNotifyCount=$(notify_containers_count "${Updates[@]}")
+ else
+ UpdNotifyCount="${#Updates[@]}"
+ fi
- # To be added in the MessageBody if "-d X" was used
- # leading space is left intentionally for clean output
- [[ -n "$DaysOld" ]] && msgdaysold="with images ${DaysOld}+ days old " || msgdaysold=""
+ NotifyError=false
- MessageTitle="$FromHost - updates ${msgdaysold}available."
- # Setting the MessageBody variable here.
- printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n${UpdToString}\n"
+ if [[ "${UpdNotifyCount}" -gt 0 ]]; then
+ UpdToString=$( printf '%s\\n' "${Updates[@]}" )
+ UpdToString=${UpdToString%\\n}
- exec_if_exists_or_fail trigger_${channel}_notification || \
- printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
- done
+ for channel in "${enabled_notify_channels[@]}"; do
+ printf "\nSending ${channel} notification\n"
+
+ # To be added in the MessageBody if "-d X" was used
+ # leading space is left intentionally for clean output
+ [[ -n "$DaysOld" ]] && msgdaysold="with images ${DaysOld}+ days old " || msgdaysold=""
+
+ MessageTitle="$FromHost - updates ${msgdaysold}available."
+ # Setting the MessageBody variable here.
+ printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n${UpdToString}\n"
+
+ exec_if_exists_or_fail trigger_${channel}_notification || \
+ printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
+ done
+
+ [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}"
+ fi
+
+ [[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}"
}
### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
- if [[ ! "${DISABLE_DOCKCHECK_NOTIFICATION:-}" = "true" ]]; then
- MessageTitle="$FromHost - New version of dockcheck available."
- # Setting the MessageBody variable here.
- printf -v MessageBody "Installed version: $1\nLatest version: $2\n\nChangenotes: $3\n"
+ if [[ ! "${DISABLE_DOCKCHECK_NOTIFICATION:-}" == "true" ]]; then
+ DockcheckNotify=false
+ NotifyError=false
- if [[ ${#enabled_notify_channels[@]} -gt 0 ]]; then printf "\n"; fi
- for channel in "${enabled_notify_channels[@]}"; do
- printf "Sending dockcheck update notification - ${channel}\n"
- exec_if_exists_or_fail trigger_${channel}_notification || \
- printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
- done
+ if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
+ found=$(grep -w "dockcheck\.sh" "${SnoozeFile}" || printf "")
+ if [[ -n "${found}" ]]; then
+ read -a arr <<< "${found}"
+ CheckEpochSeconds=$(( $(date -d "${arr[1]}" +%s 2>/dev/null) + ${snooze} - 60 )) || CheckEpochSeconds=$(( $(date -f "%Y-%m-%d" -j "${arr[1]}" +%s) + ${snooze} - 60 ))
+ if [[ "${CurrentEpochSeconds}" -gt "${CheckEpochSeconds}" ]]; then
+ DockcheckNotify=true
+ fi
+ else
+ DockcheckNotify=true
+ fi
+ else
+ DockcheckNotify=true
+ fi
+
+ if [[ "${DockcheckNotify}" == "true" ]]; then
+ MessageTitle="$FromHost - New version of dockcheck available."
+ # Setting the MessageBody variable here.
+ printf -v MessageBody "Installed version: $1\nLatest version: $2\n\nChangenotes: $3\n"
+
+ if [[ ${#enabled_notify_channels[@]} -gt 0 ]]; then printf "\n"; fi
+ for channel in "${enabled_notify_channels[@]}"; do
+ printf "Sending dockcheck update notification - ${channel}\n"
+ exec_if_exists_or_fail trigger_${channel}_notification || \
+ printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
+ done
+
+ if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
+ if [[ "${NotifyError}" == "false" ]]; then
+ if [[ -n "${found}" ]]; then
+ sed -e "s/dockcheck\.sh.*/dockcheck\.sh ${CurrentEpochTime}/" "${SnoozeFile}" > "${SnoozeFile}.new"
+ mv "${SnoozeFile}.new" "${SnoozeFile}"
+ else
+ printf "dockcheck.sh ${CurrentEpochTime}\n" >> "${SnoozeFile}"
+ fi
+ fi
+ fi
+ fi
fi
}
### Set DISABLE_NOTIFY_UPDATE_NOTIFICATION=false in dockcheck.config
### to not send notifications when notify scripts themselves have updates.
notify_update_notification() {
- if [[ ! "${DISABLE_NOTIFY_UPDATE_NOTIFICATION:-}" = "true" ]]; then
- update_channels=( "${enabled_notify_channels[@]}" "v2" )
+ if [[ ! "${DISABLE_NOTIFY_UPDATE_NOTIFICATION:-}" == "true" ]]; then
+ NotifyUpdateNotify=false
+ NotifyError=false
- for notify_script in "${update_channels[@]}"; do
- upper_channel=$(tr '[:lower:]' '[:upper:]' <<< "$notify_script")
- VersionVar="NOTIFY_${upper_channel}_VERSION"
+ UpdateChannels=( "${enabled_notify_channels[@]}" "v2" )
+
+ for NotifyScript in "${UpdateChannels[@]}"; do
+ UpperChannel=$(tr '[:lower:]' '[:upper:]' <<< "$NotifyScript")
+ VersionVar="NOTIFY_${UpperChannel}_VERSION"
if [[ -n "${!VersionVar:-}" ]]; then
- RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_${notify_script}.sh"
- LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_${upper_channel}_VERSION/s/NOTIFY_${upper_channel}_VERSION=//p" | tr -d '"')"
- LatestNotifyRelease=${LatestNotifyRelease:-undefined}
- if [[ ! "${LatestNotifyRelease}" = "undefined" ]]; then
- if [[ "${!VersionVar}" != "$LatestNotifyRelease" ]] ; then
- MessageTitle="$FromHost - New version of notify_${notify_script}.sh available."
-
- printf -v MessageBody "notify_${notify_script}.sh update available:\n ${!VersionVar} -> $LatestNotifyRelease\n"
-
- for channel in "${enabled_notify_channels[@]}"; do
- printf "Sending notify_${notify_script}.sh update notification - ${channel}\n"
- exec_if_exists_or_fail trigger_${channel}_notification || \
- printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
- done
+ RawNotifyUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/notify_templates/notify_${NotifyScript}.sh"
+ LatestNotifySnippet="$(curl ${CurlArgs} -r 0-150 "$RawNotifyUrl" || printf "undefined")"
+ LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
+ if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then
+ if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then
+ Updates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
fi
fi
fi
done
+
+ if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
+ for update in "${Updates[@]}"; do
+ read -a NotifyScript <<< "${update}"
+ found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "")
+ if [[ -n "${found}" ]]; then
+ read -a arr <<< "${found}"
+ CheckEpochSeconds=$(( $(date -d "${arr[1]}" +%s 2>/dev/null) + ${snooze} - 60 )) || CheckEpochSeconds=$(( $(date -f "%Y-%m-%d" -j "${arr[1]}" +%s) + ${snooze} - 60 ))
+ if [[ "${CurrentEpochSeconds}" -gt "${CheckEpochSeconds}" ]]; then
+ NotifyUpdateNotify=true
+ fi
+ else
+ NotifyUpdateNotify=true
+ fi
+ done
+ else
+ NotifyUpdateNotify=true
+ fi
+
+ if [[ "${NotifyUpdateNotify}" == "true" ]]; then
+ if [[ "${#Updates[@]}" -gt 0 ]]; then
+ UpdToString=$( printf '%s\\n' "${Updates[@]}" )
+ UpdToString=${UpdToString%\\n}
+ NotifyError=false
+
+ MessageTitle="$FromHost - New version of notify templates available."
+
+ printf -v MessageBody "Notify templates on $FromHost with updates available:\n${UpdToString}\n"
+
+ for channel in "${enabled_notify_channels[@]}"; do
+ printf "Sending notify template update notification - ${channel}\n"
+ exec_if_exists_or_fail trigger_${channel}_notification || \
+ printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
+ done
+
+ [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}"
+ fi
+ fi
+
+ UpdatesPlusDockcheck=("${Updates[@]}")
+ UpdatesPlusDockcheck+=("dockcheck.sh")
+ [[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}"
fi
}
From 77f024bb81a741fbc74638ab3e267b17ea8c5e72 Mon Sep 17 00:00:00 2001
From: vorezal <37914382+vorezal@users.noreply.github.com>
Date: Fri, 27 Jun 2025 03:10:31 -0400
Subject: [PATCH 05/41] Fix unbound variable, potential collision, and config
variable. (#209)
* Fix unbound variable, potential collision, and config variable.
* Return 0 when notification functions finish successfully
---------
Co-authored-by: Matthew Oleksowicz
---
notify_templates/notify_v2.sh | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/notify_templates/notify_v2.sh b/notify_templates/notify_v2.sh
index a34acfa..3329512 100644
--- a/notify_templates/notify_v2.sh
+++ b/notify_templates/notify_v2.sh
@@ -139,6 +139,8 @@ send_notification() {
fi
[[ -n "${snooze}" ]] && cleanup_snooze "${Updates[@]}"
+
+ return 0
}
### Set DISABLE_DOCKCHECK_NOTIFICATION=false in dockcheck.config
@@ -187,14 +189,17 @@ dockcheck_notification() {
fi
fi
fi
+
+ return 0
}
-### Set DISABLE_NOTIFY_UPDATE_NOTIFICATION=false in dockcheck.config
+### Set DISABLE_NOTIFY_NOTIFICATION=false in dockcheck.config
### to not send notifications when notify scripts themselves have updates.
notify_update_notification() {
- if [[ ! "${DISABLE_NOTIFY_UPDATE_NOTIFICATION:-}" == "true" ]]; then
+ if [[ ! "${DISABLE_NOTIFY_NOTIFICATION:-}" == "true" ]]; then
NotifyUpdateNotify=false
NotifyError=false
+ NotifyUpdates=()
UpdateChannels=( "${enabled_notify_channels[@]}" "v2" )
@@ -207,14 +212,14 @@ notify_update_notification() {
LatestNotifyRelease="$(echo "$LatestNotifySnippet" | sed -n "/${VersionVar}/s/${VersionVar}=//p" | tr -d '"')"
if [[ ! "${LatestNotifyRelease}" == "undefined" ]]; then
if [[ "${!VersionVar}" != "${LatestNotifyRelease}" ]] ; then
- Updates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
+ NotifyUpdates+=("${NotifyScript}.sh ${!VersionVar} -> ${LatestNotifyRelease}")
fi
fi
fi
done
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
- for update in "${Updates[@]}"; do
+ for update in "${NotifyUpdates[@]}"; do
read -a NotifyScript <<< "${update}"
found=$(grep -w "${NotifyScript}" "${SnoozeFile}" || printf "")
if [[ -n "${found}" ]]; then
@@ -232,8 +237,8 @@ notify_update_notification() {
fi
if [[ "${NotifyUpdateNotify}" == "true" ]]; then
- if [[ "${#Updates[@]}" -gt 0 ]]; then
- UpdToString=$( printf '%s\\n' "${Updates[@]}" )
+ if [[ "${#NotifyUpdates[@]}" -gt 0 ]]; then
+ UpdToString=$( printf '%s\\n' "${NotifyUpdates[@]}" )
UpdToString=${UpdToString%\\n}
NotifyError=false
@@ -247,12 +252,14 @@ notify_update_notification() {
printf "Attempted to send notification to channel ${channel}, but the function was not found. Make sure notify_${channel}.sh is available in the ${ScriptWorkDir} directory or notify_templates subdirectory.\n"
done
- [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${Updates[@]}"
+ [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "${NotifyUpdates[@]}"
fi
fi
- UpdatesPlusDockcheck=("${Updates[@]}")
+ UpdatesPlusDockcheck=("${NotifyUpdates[@]}")
UpdatesPlusDockcheck+=("dockcheck.sh")
[[ -n "${snooze}" ]] && cleanup_snooze "${UpdatesPlusDockcheck[@]}"
fi
+
+ return 0
}
From d37e1a102434b17ac9f0e5bcaee607839ecf2262 Mon Sep 17 00:00:00 2001
From: mag37
Date: Fri, 27 Jun 2025 09:22:10 +0200
Subject: [PATCH 06/41] Bugfixes for unbound variable, potential collision and
config variable mismatch
Version bump to alert users of the latest bugfixes for unbound variable, potential collision and config variable mismatch.
---
notify_templates/notify_v2.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notify_templates/notify_v2.sh b/notify_templates/notify_v2.sh
index 3329512..c2d8538 100644
--- a/notify_templates/notify_v2.sh
+++ b/notify_templates/notify_v2.sh
@@ -1,4 +1,4 @@
-NOTIFY_V2_VERSION="v0.3"
+NOTIFY_V2_VERSION="v0.4"
#
# If migrating from an older notify template, remove your existing notify.sh file.
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
From 69c06de1bddf6ac9a691b476c80434ad6cad360a Mon Sep 17 00:00:00 2001
From: op4lat <155382511+op4lat@users.noreply.github.com>
Date: Tue, 1 Jul 2025 16:19:15 -0400
Subject: [PATCH 07/41] Add DisplaySourcedFiles variable (#207)
* Add DisplaySourcedFiles variable to be used in source_if_exists and source_if_exists_or_fail functions
* Added return 0 as to not throw wrong exit code.
* Delete source_if_exists. source_if_exists_or_fail returns success or failure. Failure doesn't stop the script
---------
Co-authored-by: Elephant Quater
Co-authored-by: mag37
---
default.config | 1 +
dockcheck.sh | 14 ++++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/default.config b/default.config
index 2831591..27bb52c 100644
--- a/default.config
+++ b/default.config
@@ -26,6 +26,7 @@
#CurlRetryDelay=1 # Time between curl retries
#CurlRetryCount=3 # Max number of curl retries
#CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing
+#DisplaySourcedFiles=false # Display what files are being sourced/used
### Notify settings
## All commented values are examples only. Modify as needed.
diff --git a/dockcheck.sh b/dockcheck.sh
index d341ce9..183027c 100755
--- a/dockcheck.sh
+++ b/dockcheck.sh
@@ -14,16 +14,18 @@ ScriptPath="$(readlink -f "$0")"
ScriptWorkDir="$(dirname "$ScriptPath")"
# Source helper functions
-source_if_exists() {
- if [[ -s "$1" ]]; then source "$1"; fi
-}
-
source_if_exists_or_fail() {
- [[ -s "$1" ]] && source "$1"
+ if [[ -s "$1" ]]; then
+ source "$1"
+ [[ "${DisplaySourcedFiles:-false}" == true ]] && echo " * sourced config: ${1}"
+ return 0
+ else
+ return 1
+ fi
}
# User customizable defaults
-source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists "${ScriptWorkDir}/dockcheck.config"
+source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists_or_fail "${ScriptWorkDir}/dockcheck.config"
# Help Function
Help() {
From a1e7446753d582aac1e41ddec23c960c08812bd0 Mon Sep 17 00:00:00 2001
From: mag37
Date: Tue, 1 Jul 2025 22:27:54 +0200
Subject: [PATCH 08/41] version bump + readme
---
README.md | 5 ++++-
dockcheck.sh | 4 ++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 751e7b2..be80a36 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,9 @@
___
## :bell: Changelog
+- **v0.6.8**:
+ - Bugfix: Unbound variable in notify_v2.sh
+ - New option: "DisplaySourcedFiles" *config* added to list what files get sourced
- **v0.6.7**: Snooze feature, curl, and consolidation
- Added snooze feature to delay notifications
- Added configurable default curl arguments
@@ -168,7 +171,7 @@ copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh
#### Snooze feature:
**Use case:** You wish to be notified of available updates in a timely manner, but do not require reminders after the initial notification with the same frequency.
e.g. *Dockcheck is scheduled to run every hour. You will receive an update notification within an hour of availability.*
-**Snooze enabled:** you will not receive another notification about updates for this container for a configurable period of time.
+**Snooze enabled:** you will not receive another notification about updates for this container for a configurable period of time.
**Snooze disabled:** you will receive additional notifications every hour.
To enable snooze, uncomment the `SNOOZE_SECONDS` variable in your `dockcheck.config` file and set it to the number of seconds you wish to prevent duplicate alerts.
diff --git a/dockcheck.sh b/dockcheck.sh
index 183027c..dafa2ce 100755
--- a/dockcheck.sh
+++ b/dockcheck.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-VERSION="v0.6.7"
-# ChangeNotes: snooze feature (see readme), curl arguments, cleanup.
+VERSION="v0.6.8"
+# ChangeNotes: bugfix unbound variable in notify_v2, new option "DisplaySourcedFiles" added to config
Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
From 98e996caa3cca8e2d048b672aa22f2d33ed90dbc Mon Sep 17 00:00:00 2001
From: mag37
Date: Mon, 7 Jul 2025 10:49:32 +0200
Subject: [PATCH 09/41] added paypay sponsor
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index be80a36..dfac061 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,11 @@
+
+
CLI tool to automate docker image updates or notifying when updates are available.
From e2dbd69c5e428b94b1b7966b257f304a890e87e1 Mon Sep 17 00:00:00 2001
From: Rasmus Lundsgaard
Date: Mon, 14 Jul 2025 13:59:07 +0200
Subject: [PATCH 10/41] first version of notification to Home Assistant (#213)
* first working version of notification to Home Assistant
* add documentation links
* update readme for notify_HA
---
README.md | 2 ++
default.config | 7 ++++++-
notify_templates/notify_HA.sh | 31 +++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletion(-)
create mode 100755 notify_templates/notify_HA.sh
diff --git a/README.md b/README.md
index dfac061..6fec3fc 100644
--- a/README.md
+++ b/README.md
@@ -147,6 +147,7 @@ Make certain your project directory is laid out as below. You only need the noti
│ ├── notify_discord.sh
│ ├── notify_generic.sh
│ ├── notify_gotify.sh
+│ ├── notify_HA.sh
│ ├── notify_matrix.sh
│ ├── notify_ntfy.sh
│ ├── notify_pushbullet.sh
@@ -190,6 +191,7 @@ If an update becomes available for an item that is not snoozed, notifications wi
- Read the [QuickStart](extras/apprise_quickstart.md)
- [ntfy](https://ntfy.sh/) - HTTP-based pub-sub notifications.
- [Gotify](https://gotify.net/) - a simple server for sending and receiving messages.
+- [Home Assistant](https://www.home-assistant.io/integrations/notify/) - Connection to the notify [integrations](https://www.home-assistant.io/integrations/#notifications).
- [Pushbullet](https://www.pushbullet.com/) - connecting different devices with cross-platform features.
- [Telegram](https://telegram.org/) - Telegram chat API.
- [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication.
diff --git a/default.config b/default.config
index 27bb52c..49457f0 100644
--- a/default.config
+++ b/default.config
@@ -32,7 +32,7 @@
## All commented values are examples only. Modify as needed.
##
## Uncomment the line below and specify the notification channels you wish to enable in a space separated string
-# NOTIFY_CHANNELS="apprise discord DSM generic gotify matrix ntfy pushbullet pushover slack smtp telegram"
+# NOTIFY_CHANNELS="apprise discord DSM generic HA gotify matrix ntfy pushbullet pushover slack smtp telegram"
#
## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze
# SNOOZE_SECONDS=86400
@@ -57,6 +57,10 @@
# GOTIFY_DOMAIN="https://gotify.domain.tld"
# GOTIFY_TOKEN="token-value"
#
+# HA_ENTITY="entity"
+# HA_TOKEN="token"
+# HA_URL="https://your.homeassistant.url"
+#
# MATRIX_ACCESS_TOKEN="token-value"
# MATRIX_ROOM_ID="myroom"
# MATRIX_SERVER_URL="https://matrix.yourdomain.tld"
@@ -82,3 +86,4 @@
# TELEGRAM_CHAT_ID="mychatid"
# TELEGRAM_TOKEN="token-value"
# TELEGRAM_TOPIC_ID="0"
+
diff --git a/notify_templates/notify_HA.sh b/notify_templates/notify_HA.sh
new file mode 100755
index 0000000..dda74be
--- /dev/null
+++ b/notify_templates/notify_HA.sh
@@ -0,0 +1,31 @@
+### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
+NOTIFY_HA_VERSION="v0.1"
+#
+# This is an integration that makes it possible to send notifications via Home Assistant (https://www.home-assistant.io/integrations/notify/)
+# You need to generate a long-lived access token in Home Sssistant to be used here (https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token)
+# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
+# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script.
+# Do not modify this file directly within the "notify_templates" subdirectory. Set HA_ENTITY, HA_URL and HA_TOKEN in your dockcheck.config file.
+
+if [[ -z "${HA_ENTITY:-}" ]] || [[ -z "${HA_URL:-}" ]] || [[ -z "${HA_TOKEN:-}" ]]; then
+ printf "Home Assistant notification channel enabled, but required configuration variables are missing. Home assistant notifications will not be sent.\n"
+
+ remove_channel HA
+fi
+
+trigger_HA_notification() {
+ AccessToken="${HA_TOKEN}"
+ Url="${HA_URL}/api/services/notify/${HA_ENTITY}"
+ JsonData=$( "$jqbin" -n \
+ --arg body "$MessageBody" \
+ '{"title": "dockcheck update", "message": $body}' )
+
+ curl -S -o /dev/null ${CurlArgs} \
+ -H "Authorization: Bearer $AccessToken" \
+ -H "Content-Type: application/json" \
+ -d "$JsonData" -X POST $Url
+
+ if [[ $? -gt 0 ]]; then
+ NotifyError=true
+ fi
+}
From cfa74adc3db524e4e89b5dcfb562f8d0d666d4fa Mon Sep 17 00:00:00 2001
From: mag37
Date: Sat, 19 Jul 2025 00:40:50 +0200
Subject: [PATCH 11/41] added new logo
---
extras/dockcheck_colour.png | Bin 0 -> 147760 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 extras/dockcheck_colour.png
diff --git a/extras/dockcheck_colour.png b/extras/dockcheck_colour.png
new file mode 100644
index 0000000000000000000000000000000000000000..1ae6f8f14c0ce2c007c4756d896e0d0c72a59f8d
GIT binary patch
literal 147760
zcmeFZXH=9~(>99ZC^H5SL6GdgC;|c^NND0HK|w)4K*@p%l0%b2<1i{2QGy~3DmGC-
zBxjK*AUR2fCP=2qxliq8p6B~cSnK>b|IXWMG4wR|z3;tiS6y}0Rl5zirKWuR2+I*F
zDyrkxuPJC!QBnVfettU)pPYXg`4oQrZh!5r6BQNvGxT#HY@GA}K4iu!-oa|wJ;b`+
zb9_MM>gp=^$kxiq?4JDtK|4qDH}ldgR8(iEt}Fa?+bwo>VAH98-FtG=mD57hx90c>
zs^15HrPcVLpc3^!-(|EfeDwMQzL!6~%{FD~=jP^;zwR8`HnzS=`26PeeV3E9#6MkJ
zysm$KfM>W)I``L!KM$N(A1IY;d6#~N`p_>MZ@0JIZfDh5R*Y$#O-pSR@|GPkNY^US
zIRJnD@{IYn1HO&P<7wOP8Oc`DG`=48Z$YZ{B
zgB^Z7e?Z-QtU4fbHq2nK^F4fEO^YJmI^l{irvUzYtLCFnO;zETdRkmWeYJ({Ga6~TTiyItSw$rrX$|meWpOfhJoiqFe!%!<=bc!?
z(D5go$=X(ZyZH?~7PkD=*+Y^iy|*!1NoWqj$oG5h-yAp1S