Compare commits

...

10 Commits

Author SHA1 Message Date
mag37
37f33d7a06 Snooze bugfix, added auth support to ntfy.sh and sendmail support to SMTP 2025-08-11 21:36:51 +02:00
vorezal
732a5e69cd Reword disable notification comment for clarity and use update_snooze for dockcheck notifications. (#221)
Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
2025-08-11 21:17:01 +02:00
op4lat
9156cc44e1 Ntfy.sh and authentication (#220)
* default.config: add NtfyAuth=

* notify_templates/notify_ntfy.sh: implement NtfyAuth

---------

Co-authored-by: Lat <lat@mail.com>
Co-authored-by: mag37 <robin.ivehult@gmail.com>
2025-08-11 21:16:38 +02:00
xmirakulix
fbc9a252f5 update SMTP template, added suport for sendmail (#219)
* update smtp template, add suport for sendmail

* add sendmail to DSM and bump version

* correct errormsg and version number
2025-08-02 08:04:43 +02:00
mag37
1f374b5003 clarifying ntfy.sh
"domain" is a bit misleading, so clarifying that https:// is needed. Might change to "NTFY_URL" in the future.
2025-07-27 15:06:35 +02:00
mag37
563dbb8b42 Label bugfix, search filtering fix (#216)
* search filtering fix
* skip recreation if no label when -l option used + clarification
* changed readme + help to correctly show help example
2025-07-25 10:35:49 +02:00
mag37
31bb2008b9 new logo 2025-07-19 00:41:43 +02:00
mag37
cfa74adc3d added new logo 2025-07-19 00:40:50 +02:00
Rasmus Lundsgaard
e2dbd69c5e first version of notification to Home Assistant (#213)
* first working version of notification to Home Assistant

* add documentation links

* update readme for notify_HA
2025-07-14 13:59:07 +02:00
mag37
98e996caa3 added paypay sponsor 2025-07-07 10:49:32 +02:00
9 changed files with 89 additions and 45 deletions

View File

@@ -1,13 +1,15 @@
<p align="center"> <p align="center">
<img src="extras/dockcheck_logo_by_booYah187.png" width="160" title="dockcheck"> <img src="extras/dockcheck_colour.png" width="300" title="dockcheck">
</p> </p>
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/bash-4.3-green?style=flat-square&logo=gnubash" alt="bash"> <img src="https://img.shields.io/badge/bash-4.3-green?style=flat-square&logo=gnubash" alt="bash">
<a href="https://www.gnu.org/licenses/gpl-3.0.html"><img src="https://img.shields.io/badge/license-GPLv3-red?style=flat-square" alt="GPLv3"></a> <a href="https://www.gnu.org/licenses/gpl-3.0.html"><img src="https://img.shields.io/badge/license-GPLv3-red?style=flat-square" alt="GPLv3"></a>
<img src="https://img.shields.io/github/v/tag/mag37/dockcheck?style=flat-square&label=release" alt="release"> <img src="https://img.shields.io/github/v/tag/mag37/dockcheck?style=flat-square&label=release" alt="release">
<br>
<a href="https://ko-fi.com/mag37"><img src="https://img.shields.io/badge/-Ko--fi-grey?style=flat-square&logo=Ko-fi" alt="Buy me a Coffee"></a> <a href="https://ko-fi.com/mag37"><img src="https://img.shields.io/badge/-Ko--fi-grey?style=flat-square&logo=Ko-fi" alt="Buy me a Coffee"></a>
<a href="https://liberapay.com/user-bin-rob/donate"><img src="https://img.shields.io/badge/-LiberaPay-grey?style=flat-square&logo=liberapay" alt="LiberaPay"></a> <a href="https://liberapay.com/user-bin-rob/donate"><img src="https://img.shields.io/badge/-LiberaPay-grey?style=flat-square&logo=liberapay" alt="LiberaPay"></a>
<a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a> <a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a>
<a href="https://www.paypal.com/donate/?business=P2V5MCWRGCNBG&no_recurring=0&currency_code=SEK"><img src="https://img.shields.io/badge/-PayPal-grey?style=flat-square&logo=paypal" alt="PayPal donation"></a>
</p> </p>
<h2 align="center">CLI tool to automate docker image updates or notifying when updates are available.</h2> <h2 align="center">CLI tool to automate docker image updates or notifying when updates are available.</h2>
@@ -20,6 +22,14 @@
___ ___
## :bell: Changelog ## :bell: Changelog
- **v0.7.0**:
- Bugfix: snooze dockcheck.sh-self-notification and some config clarification.
- Added authentication support to Ntfy.sh.
- Added suport for sendmail in the SMTP-template.
- **v0.6.9**:
- Bugfix: label logic didn't skip recreation (skipped pulling).
- Added comma separated search filtering so you can selectively search exactly which containers to check/update.
- eg: `dockcheck.sh -yp homer,dozzle`
- **v0.6.8**: - **v0.6.8**:
- Bugfix: Unbound variable in notify_v2.sh - Bugfix: Unbound variable in notify_v2.sh
- New option: "DisplaySourcedFiles" *config* added to list what files get sourced - New option: "DisplaySourcedFiles" *config* added to list what files get sourced
@@ -28,20 +38,6 @@ ___
- Added configurable default curl arguments - Added configurable default curl arguments
- Consolidated and standardized notify template update notifications - Consolidated and standardized notify template update notifications
- Added curl error handling - Added curl error handling
- **v0.6.6**: Notify_v2 bugfixes
- Clearer readme and error messages
- Sourcing templates from either project root or subdirectory
- Consistent newline handling
- Added (when using `-d`) days old message to notification title
- 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.
- Created notify_v2.sh wrapper script.
- Simplified and consolidated notification logic within notify_v2.sh.
- 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.
___ ___
@@ -50,7 +46,7 @@ ___
## :mag_right: `dockcheck.sh` ## :mag_right: `dockcheck.sh`
``` ```
$ ./dockcheck.sh -h $ ./dockcheck.sh -h
Syntax: dockcheck.sh [OPTION] [part of name to filter] Syntax: dockcheck.sh [OPTION] [comma separated names to include]
Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall
Options: Options:
@@ -145,6 +141,7 @@ Make certain your project directory is laid out as below. You only need the noti
│ ├── notify_discord.sh │ ├── notify_discord.sh
│ ├── notify_generic.sh │ ├── notify_generic.sh
│ ├── notify_gotify.sh │ ├── notify_gotify.sh
│ ├── notify_HA.sh
│ ├── notify_matrix.sh │ ├── notify_matrix.sh
│ ├── notify_ntfy.sh │ ├── notify_ntfy.sh
│ ├── notify_pushbullet.sh │ ├── notify_pushbullet.sh
@@ -188,6 +185,7 @@ If an update becomes available for an item that is not snoozed, notifications wi
- Read the [QuickStart](extras/apprise_quickstart.md) - Read the [QuickStart](extras/apprise_quickstart.md)
- [ntfy](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. - [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. - [Pushbullet](https://www.pushbullet.com/) - connecting different devices with cross-platform features.
- [Telegram](https://telegram.org/) - Telegram chat API. - [Telegram](https://telegram.org/) - Telegram chat API.
- [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication. - [Matrix-Synapse](https://github.com/element-hq/synapse) - [Matrix](https://matrix.org/), open, secure, decentralised communication.

View File

@@ -32,14 +32,14 @@
## All commented values are examples only. Modify as needed. ## 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 ## 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 ## Uncomment the line below and specify the number of seconds to delay notifications to enable snooze
# SNOOZE_SECONDS=86400 # SNOOZE_SECONDS=86400
# #
## Uncomment to not send notifications when dockcheck itself has updates. ## Uncomment and set to true to disable notifications when dockcheck itself has updates.
# DISABLE_DOCKCHECK_NOTIFICATION=false # DISABLE_DOCKCHECK_NOTIFICATION=false
## Uncomment to not send notifications when notify scripts themselves have updates. ## Uncomment and set to true to disable notifications when notify scripts themselves have updates.
# DISABLE_NOTIFY_NOTIFICATION=false # DISABLE_NOTIFY_NOTIFICATION=false
# #
## Apprise configuration variables. Set APPRISE_PAYLOAD to make a CLI call or set APPRISE_URL to make an API request instead. ## Apprise configuration variables. Set APPRISE_PAYLOAD to make a CLI call or set APPRISE_URL to make an API request instead.
@@ -57,13 +57,18 @@
# GOTIFY_DOMAIN="https://gotify.domain.tld" # GOTIFY_DOMAIN="https://gotify.domain.tld"
# GOTIFY_TOKEN="token-value" # GOTIFY_TOKEN="token-value"
# #
# HA_ENTITY="entity"
# HA_TOKEN="token"
# HA_URL="https://your.homeassistant.url"
#
# MATRIX_ACCESS_TOKEN="token-value" # MATRIX_ACCESS_TOKEN="token-value"
# MATRIX_ROOM_ID="myroom" # MATRIX_ROOM_ID="myroom"
# MATRIX_SERVER_URL="https://matrix.yourdomain.tld" # MATRIX_SERVER_URL="https://matrix.yourdomain.tld"
# #
## ntfy.sh or your custom domain with no trailing / ## https://ntfy.sh or your custom domain with https:// and no trailing /
# NTFY_DOMAIN="ntfy.sh" # NTFY_DOMAIN="https://ntfy.sh"
# NTFY_TOPIC_NAME="YourUniqueTopicName" # NTFY_TOPIC_NAME="YourUniqueTopicName"
# NTFY_AUTH="" # set to either format -> "user:password" OR ":tk_12345678". If using tokens, don't forget the ":"
# #
# PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes" # PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes"
# PUSHBULLET_TOKEN="token-value" # PUSHBULLET_TOKEN="token-value"
@@ -82,3 +87,4 @@
# TELEGRAM_CHAT_ID="mychatid" # TELEGRAM_CHAT_ID="mychatid"
# TELEGRAM_TOKEN="token-value" # TELEGRAM_TOKEN="token-value"
# TELEGRAM_TOPIC_ID="0" # TELEGRAM_TOPIC_ID="0"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.6.8" VERSION="v0.7.0"
# ChangeNotes: bugfix unbound variable in notify_v2, new option "DisplaySourcedFiles" added to config # ChangeNotes: Snooze bugfix, added auth support to ntfy.sh and sendmail support to SMTP
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"
@@ -29,7 +29,7 @@ source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists_
# Help Function # Help Function
Help() { Help() {
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]" echo "Syntax: dockcheck.sh [OPTION] [comma separated names to include]"
echo "Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall" echo "Example: dockcheck.sh -y -x 10 -d 10 -e nextcloud,heimdall"
echo echo
echo "Options:" echo "Options:"
@@ -121,8 +121,11 @@ while getopts "ayfFhiIlmMnprsuvc:e:d:t:x:" options; do
done done
shift "$((OPTIND-1))" shift "$((OPTIND-1))"
# Set $1 to a variable for name filtering later # Set $1 to a variable for name filtering later, rewriting if multiple
SearchName="${1:-}" SearchName="${1:-}"
if [[ ! -z "$SearchName" ]]; then
SearchName="^(${SearchName//,/|})$"
fi
# Check if there's a new release of the script # Check if there's a new release of the script
LatestSnippet="$(curl ${CurlArgs} -r 0-200 "$RawUrl" || printf "undefined")" LatestSnippet="$(curl ${CurlArgs} -r 0-200 "$RawUrl" || printf "undefined")"
@@ -570,8 +573,11 @@ if [[ -n "${GotUpdates:-}" ]]; then
ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels") ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels")
[[ "$ContOnlySpecific" == "null" ]] && ContRestartStack="" [[ "$ContOnlySpecific" == "null" ]] && ContRestartStack=""
printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
# Checking if compose-values are empty - hence started with docker run # Checking if compose-values are empty - hence started with docker run
[[ -z "$ContPath" ]] && continue [[ -z "$ContPath" ]] && { echo "Not a compose container, skipping."; continue; }
# Checking if Label Only -option is set, and if container got the label
[[ "$OnlyLabel" == true ]] && { [[ "$ContUpdateLabel" != true ]] && { echo "No update label, skipping."; continue; } }
# cd to the compose-file directory to account for people who use relative volumes # 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; } cd "$ContPath" || { printf "\n%bPath error - skipping%b %s" "$c_red" "$c_reset" "$i"; continue; }
@@ -587,7 +593,6 @@ if [[ -n "${GotUpdates:-}" ]]; then
# Set variable when compose up should only target the specific container, not the stack # Set variable when compose up should only target the specific container, not the stack
if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi if [[ $OnlySpecific == true ]] || [[ $ContOnlySpecific == true ]]; then SpecificContainer="$ContName"; fi
printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset"
# Check if the whole stack should be restarted # Check if the whole stack should be restarted
if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then
${DockerBin} ${CompleteConfs} stop; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } ${DockerBin} ${CompleteConfs} stop; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }

BIN
extras/dockcheck_colour.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

View File

@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
NOTIFY_DSM_VERSION="v0.3" NOTIFY_DSM_VERSION="v0.4"
# INFO: ssmtp is deprecated - consider to use msmtp instead. # INFO: ssmtp is deprecated - consider to use msmtp instead.
# #
# mSMTP/sSMTP has to be installed and configured manually. # mSMTP/sSMTP has to be installed and configured manually.
@@ -10,13 +10,16 @@ NOTIFY_DSM_VERSION="v0.3"
MSMTP=$(which msmtp) MSMTP=$(which msmtp)
SSMTP=$(which ssmtp) SSMTP=$(which ssmtp)
SENDMAIL=$(which sendmail)
if [ -n "$MSMTP" ] ; then if [ -n "$MSMTP" ] ; then
MailPkg=$MSMTP MailPkg=$MSMTP
elif [ -n "$SSMTP" ] ; then elif [ -n "$SSMTP" ] ; then
MailPkg=$SSMTP MailPkg=$SSMTP
elif [ -n "$SENDMAIL" ] ; then
MailPkg=$SENDMAIL
else else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 echo "No msmtp, ssmtp or sendmail binary found in PATH: $PATH" ; exit 1
fi fi
trigger_DSM_notification() { trigger_DSM_notification() {

31
notify_templates/notify_HA.sh Executable file
View File

@@ -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
}

View File

@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
NOTIFY_NTFYSH_VERSION="v0.5" NOTIFY_NTFYSH_VERSION="v0.6"
# #
# Setup app and subscription at https://ntfy.sh # 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. # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -24,11 +24,18 @@ trigger_ntfy_notification() {
ContentType="Markdown: no" #text/plain ContentType="Markdown: no" #text/plain
fi fi
if [[ -n "${NTFY_AUTH:-}" ]]; then
NtfyAuth="-u $NTFY_AUTH"
else
NtfyAuth=""
fi
curl -S -o /dev/null ${CurlArgs} \ curl -S -o /dev/null ${CurlArgs} \
-H "Title: $MessageTitle" \ -H "Title: $MessageTitle" \
-H "$ContentType" \ -H "$ContentType" \
-d "$MessageBody" \ -d "$MessageBody" \
"$NtfyUrl" $NtfyAuth \
-L "$NtfyUrl"
if [[ $? -gt 0 ]]; then if [[ $? -gt 0 ]]; then
NotifyError=true NotifyError=true

View File

@@ -1,5 +1,5 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
NOTIFY_SMTP_VERSION="v0.3" NOTIFY_SMTP_VERSION="v0.4"
# INFO: ssmtp is depcerated - consider to use msmtp instead. # INFO: ssmtp is depcerated - consider to use msmtp instead.
# #
# mSMTP/sSMTP has to be installed and configured manually. # mSMTP/sSMTP has to be installed and configured manually.
@@ -15,13 +15,16 @@ fi
MSMTP=$(which msmtp) MSMTP=$(which msmtp)
SSMTP=$(which ssmtp) SSMTP=$(which ssmtp)
SENDMAIL=$(which sendmail)
if [ -n "$MSMTP" ] ; then if [ -n "$MSMTP" ] ; then
MailPkg=$MSMTP MailPkg=$MSMTP
elif [ -n "$SSMTP" ] ; then elif [ -n "$SSMTP" ] ; then
MailPkg=$SSMTP MailPkg=$SSMTP
elif [ -n "$SENDMAIL" ] ; then
MailPkg=$SENDMAIL
else else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 echo "No msmtp, ssmtp or sendmail binary found in PATH: $PATH" ; exit 1
fi fi
trigger_smtp_notification() { trigger_smtp_notification() {

View File

@@ -1,4 +1,4 @@
NOTIFY_V2_VERSION="v0.4" NOTIFY_V2_VERSION="v0.5"
# #
# If migrating from an older notify template, remove your existing notify.sh file. # 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. # Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
@@ -177,16 +177,7 @@ dockcheck_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" 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 done
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then [[ -n "${snooze}" ]] && [[ "${NotifyError}" == "false" ]] && update_snooze "dockcheck.sh"
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
fi fi