Compare commits

..

13 Commits

Author SHA1 Message Date
vorezal
a0e11de383 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 <matt@everyoneneeds.it>
Co-authored-by: mag37 <robin.ivehult@gmail.com>
2025-06-24 15:16:48 +02:00
mag37
272615166e ntfy rename
Corrected all mentions of the ntfy template with its new name.
Also clarified the help message of the -r option.
2025-05-31 22:05:35 +02:00
mag37
4a16d2f1ea -r clarification
Clarified the help message for the -r option.
2025-05-31 22:02:52 +02:00
Christopher Berg
67648efbe8 ntfy notification bug fixes (#197) 2025-05-31 21:55:21 +02:00
mag37
68c057e62d v0.6.6 bump and info 2025-05-29 23:03:46 +02:00
vorezal
57650f1673 Notify_v2.sh bug fixes (#188)
* Notify_v2.sh bug fixes

* Clarify notify_v2.sh usage in README.md

* Fix JSON newline handling in Discord and Telegram channels

* Additional error messages when notification templates fail to be sourced

* Additional variable for self-hosted ntfy.sh domain

* Notify_v2.sh additional fixes

* Clarify usage in README.md and notify template comments

* Support sourcing template files from project root

* Add days old message to notification title

* Handle JSON with jq in Discord and Telegram templates

* Tweak notify_v2.sh usage docs and comments

* Remove extra newline from notification body

* replaced jq with jqbin, reodered setting of jqbin, changed source for hostname var

* moved the setting of jqbin a bit further up after further testing

---------

Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
Co-authored-by: mag37 <robin.ivehult@gmail.com>
2025-05-29 22:43:34 +02:00
mag37
22871442db hotfix suppress noise
Suppressed noise about not being able to source notification (new function) when on legacy notification template.
2025-05-26 07:27:51 +02:00
mag37
ec09612274 version bump
Version bump after minor tweaks.
Should probably learn to squash properly.. soon!
2025-05-25 18:44:20 +02:00
mag37
5e7d4f0b8a minor tweaks; curl/wget retries, missing variable fix in root-check 2025-05-25 18:39:34 +02:00
mag37
57f7580477 Update dockcheck.sh
lowering version until a few more tweaks are done.
2025-05-25 18:27:12 +02:00
vorezal
c63e2441fa Refactor notifications and add helper functions (#182)
* Refactor notifications and add helper functions

* Add helper functions to simplify sourcing files and executing functions if they exist

* Create notify_v2.sh wrapper script

* Simplify and consolidate notification logic within notify_v2.sh

* Support notification management via environment variables

* Move secrets to dockcheck.config

* Fix NOTIFY_CHANNELS default value when not set

* Feedback changes

* Remove leading spaces from MessageBody

* Check for valid notify v2 variables

* Warn on missing configuration and bypass notifications

* Update readme

* Additional feedback fixes

* More comments in default.config with different # depth for comments and settings

* Rename NOTIFY_TOPIC_NAME variable to NTFY_TOPIC_NAME for consistency

* Add TELEGRAM_TOPIC_ID

* Fix AppriseURL variable

* Add an ending newline to all MessageBody statements for consistency

* Remove troubleshooting echo statement

* Prevent attempting to trigger notifications for notification templates if versions are the same

---------

Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
2025-05-25 18:26:13 +02:00
mag37
e4b93d113c fixed variable errors 2025-05-15 15:49:49 +02:00
mag37
b2d80d036a info about -r option 2025-05-14 20:55:09 +02:00
19 changed files with 807 additions and 675 deletions

4
.gitignore vendored
View File

@@ -1,7 +1,9 @@
# ignore users custom notify.sh # ignore users custom notify.sh
/notify.sh /notify*.sh
/urls.list /urls.list
# ignore user config # ignore user config
/dockcheck.config /dockcheck.config
# ignore the auto-installed regctl # ignore the auto-installed regctl
regctl regctl
# ignore snooze file
snooze.list

109
README.md
View File

@@ -20,24 +20,25 @@
___ ___
## :bell: Changelog ## :bell: Changelog
- **v0.6.4**: Restructured the update process - first pulls all updates, then recreates all containers. - **v0.6.7**: Snooze feature, curl, and consolidation
- Added logic to skip update check on non-compose containers (unless `-r` option). - Added snooze feature to delay notifications
- Added option `-F` to revert to `compose up -d <ContainerName>` targeting specific container and not the stack. - Added configurable default curl arguments
- Also added corresponding label and config-option. - Consolidated and standardized notify template update notifications
- Added markdown formatting to `notify_ntfy-sh.sh` template. - Added curl error handling
- **v0.6.3**: Some fixes and changes: - **v0.6.6**: Notify_v2 bugfixes
- Stops when a container recreation (compose up -d) fails, also `up`s the whole stack now. - Clearer readme and error messages
- `-M`, Markdown format url-releasenotes in notification (requires template rework, look at gotify!) - Sourcing templates from either project root or subdirectory
- Added [addons/DSM/README.md](./addons/DSM/README.md) for more info Synology DSM info. - Consistent newline handling
- Permission checks - graceful exit if no docker permissions + checking if root for pkg-manager. - Added (when using `-d`) days old message to notification title
- **v0.6.2**: Style and colour changes, prometheus hotfix, new options: - Added ntfy self hosted domain option to config
- `-u`, Allow auto self update of dockcheck.sh - jq fixes to templates (and properly using $jqbin)
- `-I`, Print container release URLs in the CLI "choose update" list. (please contribute to `urls.list`) - **v0.6.5**: Refactored notification logic. See notify_templates/notify_v2.sh for upgrade steps.
- Extras: `-m`, Monochrome mode now hides the progress bar. - Added helper functions to simplify sourcing files and executing functions if they exist.
- **v0.6.1**: Hotfixes: (try removing set+shopt+shopt if debugging more errors) - Created notify_v2.sh wrapper script.
- xargs/pipefail, removed `-set -e` bash option for now. - Simplified and consolidated notification logic within notify_v2.sh.
- unbound variables fixed (hopefully) - Added support for notification management via environment variables.
- dependency installer from pkgmanager rewritten - Moved notification secrets to **dockcheck.config**.
- Added retries to wget/curl to not get empty responses when github is slow.
___ ___
@@ -58,13 +59,13 @@ Options:
-F Only compose up the specific container, not the whole compose stack (useful for master-compose structure). -F Only compose up the specific container, not the whole compose stack (useful for master-compose structure).
-h Print this Help. -h Print this Help.
-i Inform - send a preconfigured notification. -i Inform - send a preconfigured notification.
-I Prints custom releasenote urls alongside each container with updates (requires urls.list). -I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list).
-l Only update if label is set. See readme. -l Only update if label is set. See readme.
-m Monochrome mode, no printf colour codes and hides progress bar. -m Monochrome mode, no printf colour codes and hides progress bar.
-M Prints custom releasenote urls as markdown (requires template support). -M Prints custom releasenote urls as markdown (requires template support).
-n No updates, only checking availability. -n No updates, only checking availability.
-p Auto-Prune dangling images after update. -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). -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. -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. -u Allow automatic self updates - caution as this will pull new code and autorun it.
@@ -126,18 +127,63 @@ Alternatively create an alias where specific flags and values are set.
Example `alias dc=dockcheck.sh -p -x 10 -t 3`. Example `alias dc=dockcheck.sh -p -x 10 -t 3`.
## :loudspeaker: Notifications ## :loudspeaker: Notifications
Trigger with the `-i` flag if `notify.sh` is present and configured. Trigger with the `-i` flag.
If `notify.sh` is present and configured, it will be used. Otherwise, `notify_v2.sh` will be enabled.
Will send a list of containers with updates available and a notification when `dockcheck.sh` itself has an update. 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! Run it scheduled with `-ni` to only get notified when there's updates available!
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) #### Installation and configuration:
**Current templates:** 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.
```
.
├── notify_templates/
│ ├── notify_DSM.sh
│ ├── notify_apprise.sh
│ ├── notify_discord.sh
│ ├── notify_generic.sh
│ ├── notify_gotify.sh
│ ├── notify_matrix.sh
│ ├── notify_ntfy.sh
│ ├── notify_pushbullet.sh
│ ├── notify_pushover.sh
│ ├── notify_slack.sh
│ ├── notify_smtp.sh
│ ├── notify_telegram.sh
│ └── notify_v2.sh
├── dockcheck.config
├── dockcheck.sh
└── urls.list # optional
```
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 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:
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.
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) - 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)) - 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) - 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) - 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) - 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. - [Gotify](https://gotify.net/) - a simple server for sending and receiving messages.
- [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.
@@ -146,7 +192,7 @@ Use a `notify_X.sh` template file from the **notify_templates** directory, copy
- [Discord](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) - Discord webhooks. - [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 - [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!
<sub><sup>Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2).</sup></sub> <sub><sup>Initiated and first contributed by [yoyoma2](https://github.com/yoyoma2).</sup></sub>
### :date: Release notes addon ### :date: Release notes addon
@@ -189,7 +235,7 @@ See the [README.md](./addons/prometheus/README.md) for more detailed information
<sub><sup>Contributed by [tdralle](https://github.com/tdralle).</sup></sub> <sub><sup>Contributed by [tdralle](https://github.com/tdralle).</sup></sub>
### :small_orange_diamond: Zabbix config to monitor docker image updates ### :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* Example: *2 Docker Image updates on host-xyz*
See project: [thetorminal/zabbix-docker-image-updates](https://github.com/thetorminal/zabbix-docker-image-updates) See project: [thetorminal/zabbix-docker-image-updates](https://github.com/thetorminal/zabbix-docker-image-updates)
@@ -250,17 +296,18 @@ function dchk {
} }
``` ```
## :warning: `-r flag` disclaimer and warning
**Wont auto-update the containers, only their images. (compose is recommended)**
`docker run` dont support using new images just by restarting a container.
Containers need to be manually stopped, removed and created again to run on the new image.
Using the `-r` option together with eg. `-i` and `-n` to just check for updates and send notifications and not update is safe though!
## :hammer: Known issues ## :hammer: Known issues
- No detailed error feedback (just skip + list what's skipped). - No detailed error feedback (just skip + list what's skipped).
- Not respecting `--profile` options when re-creating the container. - Not respecting `--profile` options when re-creating the container.
- Not working well with containers created by **Portainer**. - Not working well with containers created by **Portainer**.
- **Watchtower** might cause issues due to retagging images when checking for updates (and thereby pulling new images). - **Watchtower** might cause issues due to retagging images when checking for updates (and thereby pulling new images).
## :warning: `-r flag` disclaimer and warning
**Wont auto-update the containers, only their images. (compose is recommended)**
`docker run` dont support using new images just by restarting a container.
Containers need to be manually stopped, removed and created again to run on the new image.
## :wrench: Debugging ## :wrench: Debugging
If you hit issues, you could check the output of the `extras/errorCheck.sh` script for clues. If you hit issues, you could check the output of the `extras/errorCheck.sh` script for clues.
Another option is to run the main script with debugging in a subshell `bash -x dockcheck.sh` - if there's a particular container/image that's causing issues you can filter for just that through `bash -x dockcheck.sh nginx`. Another option is to run the main script with debugging in a subshell `bash -x dockcheck.sh` - if there's a particular container/image that's causing issues you can filter for just that through `bash -x dockcheck.sh nginx`.

View File

@@ -1,9 +1,9 @@
### Custom user variables ### Custom user variables
# Copy this file to "dockcheck.config" to make it active ## Copy this file to "dockcheck.config" to make it active
# Can be placed in ~/.config/ or alongside dockcheck.sh ## Can be placed in ~/.config/ or alongside dockcheck.sh
# ##
# Uncomment and set your preferred configuration variables here ## Uncomment and set your preferred configuration variables here
# This will not be replaced on updates ## This will not be replaced on updates
#Timeout=10 # Set a timeout (in seconds) per container for registry checkups. #Timeout=10 # Set a timeout (in seconds) per container for registry checkups.
#MaxAsync=10 # Set max asynchronous subprocesses, 1 default, 0 to disable. #MaxAsync=10 # Set max asynchronous subprocesses, 1 default, 0 to disable.
@@ -23,3 +23,61 @@
#PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)` #PrintReleaseURL=true # Prints custom releasenote urls alongside each container with updates (requires urls.list)`
#PrintMarkdownURL=true # Prints custom releasenote urls as markdown #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). #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.
##
## 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.
# 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_PAYLOAD='mailto://myemail:mypass@gmail.com
# mastodons://{token}@{host}
# pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b
# tgram://{bot_token}/{chat_id}/'
# APPRISE_URL="http://apprise.mydomain.tld:1234/notify/apprise"
#
# DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/<token string>"
#
# DSM_SENDMAILTO="me@mydomain.com"
# DSM_SUBJECTTAG="Email Subject Prefix"
#
# GOTIFY_DOMAIN="https://gotify.domain.tld"
# GOTIFY_TOKEN="token-value"
#
# MATRIX_ACCESS_TOKEN="token-value"
# MATRIX_ROOM_ID="myroom"
# MATRIX_SERVER_URL="https://matrix.yourdomain.tld"
#
## ntfy.sh or your custom domain with no trailing /
# NTFY_DOMAIN="ntfy.sh"
# NTFY_TOPIC_NAME="YourUniqueTopicName"
#
# PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes"
# PUSHBULLET_TOKEN="token-value"
#
# PUSHOVER_URL="https://api.pushover.net/1/messages.json"
# PUSHOVER_USER_KEY="userkey"
# PUSHOVER_TOKEN="token-value"
#
# SLACK_CHANNEL_ID=mychannel
# SLACK_ACCESS_TOKEN=xoxb-token-value
#
# SMTP_MAIL_FROM="me@mydomain.tld"
# SMTP_MAIL_TO="you@yourdomain.tld"
# SMTP_SUBJECT_TAG="dockcheck"
#
# TELEGRAM_CHAT_ID="mychatid"
# TELEGRAM_TOKEN="token-value"
# TELEGRAM_TOPIC_ID="0"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.6.4" VERSION="v0.6.7"
### ChangeNotes: Restructured update process - first pulls all images, then recreates all containers. Added -F option. # ChangeNotes: snooze feature (see readme), curl arguments, cleanup.
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"
@@ -13,16 +13,17 @@ ScriptArgs=( "$@" )
ScriptPath="$(readlink -f "$0")" ScriptPath="$(readlink -f "$0")"
ScriptWorkDir="$(dirname "$ScriptPath")" ScriptWorkDir="$(dirname "$ScriptPath")"
# Check if there's a new release of the script # Source helper functions
LatestRelease="$(curl -s -r 0-50 "$RawUrl" | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" source_if_exists() {
LatestChanges="$(curl -s -r 0-200 "$RawUrl" | sed -n "/ChangeNotes/s/# ChangeNotes: //p")" if [[ -s "$1" ]]; then source "$1"; fi
}
source_if_exists_or_fail() {
[[ -s "$1" ]] && source "$1"
}
# User customizable defaults # User customizable defaults
if [[ -s "${HOME}/.config/dockcheck.config" ]]; then source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists "${ScriptWorkDir}/dockcheck.config"
source "${HOME}/.config/dockcheck.config"
elif [[ -s "${ScriptWorkDir}/dockcheck.config" ]]; then
source "${ScriptWorkDir}/dockcheck.config"
fi
# Help Function # Help Function
Help() { Help() {
@@ -38,13 +39,13 @@ Help() {
echo "-F Only compose up the specific container, not the whole compose stack (useful for master-compose structure)." echo "-F Only compose up the specific container, not the whole compose stack (useful for master-compose structure)."
echo "-h Print this Help." echo "-h Print this Help."
echo "-i Inform - send a preconfigured notification." echo "-i Inform - send a preconfigured notification."
echo "-I Prints custom releasenote urls alongside each container with updates (requires urls.list)." echo "-I Prints custom releasenote urls alongside each container with updates in CLI output (requires urls.list)."
echo "-l Only update if label is set. See readme." echo "-l Only update if label is set. See readme."
echo "-m Monochrome mode, no printf colour codes and hides progress bar." echo "-m Monochrome mode, no printf colour codes and hides progress bar."
echo "-M Prints custom releasenote urls as markdown (requires template support)." echo "-M Prints custom releasenote urls as markdown (requires template support)."
echo "-n No updates; only checking availability without interaction." echo "-n No updates; only checking availability without interaction."
echo "-p Auto-prune dangling images after update." 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 "-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 "-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." echo "-u Allow automatic self updates - caution as this will pull new code and autorun it."
@@ -55,31 +56,32 @@ Help() {
} }
# Initialise variables # Initialise variables
Timeout=${Timeout:=10} Timeout=${Timeout:-10}
MaxAsync=${MaxAsync:=1} MaxAsync=${MaxAsync:-1}
BarWidth=${BarWidth:=50} BarWidth=${BarWidth:-50}
AutoMode=${AutoMode:=false} AutoMode=${AutoMode:-false}
DontUpdate=${DontUpdate:=false} DontUpdate=${DontUpdate:-false}
AutoPrune=${AutoPrune:=false} AutoPrune=${AutoPrune:-false}
AutoSelfUpdate=${AutoSelfUpdate:=false} AutoSelfUpdate=${AutoSelfUpdate:-false}
OnlyLabel=${OnlyLabel:=false} OnlyLabel=${OnlyLabel:-false}
Notify=${Notify:=false} Notify=${Notify:-false}
ForceRestartStacks=${ForceRestartStacks:=false} ForceRestartStacks=${ForceRestartStacks:-false}
DRunUp=${DRunUp:=false} DRunUp=${DRunUp:-false}
MonoMode=${MonoMode:=false} MonoMode=${MonoMode:-false}
PrintReleaseURL=${PrintReleaseURL:=false} PrintReleaseURL=${PrintReleaseURL:-false}
PrintMarkdownURL=${PrintMarkdownURL:=false} PrintMarkdownURL=${PrintMarkdownURL:-false}
Stopped=${Stopped:=""} Stopped=${Stopped:-""}
CollectorTextFileDirectory=${CollectorTextFileDirectory:-} CollectorTextFileDirectory=${CollectorTextFileDirectory:-}
Exclude=${Exclude:-} Exclude=${Exclude:-}
DaysOld=${DaysOld:-} DaysOld=${DaysOld:-}
OnlySpecific=false OnlySpecific=${OnlySpecific:-false}
SpecificContainer=${SpecificContainer:=""} SpecificContainer=${SpecificContainer:-""}
Excludes=() Excludes=()
GotUpdates=() GotUpdates=()
NoUpdates=() NoUpdates=()
GotErrors=() GotErrors=()
SelectedUpdates=() SelectedUpdates=()
CurlArgs="--retry ${CurlRetryCount:=3} --retry-delay ${CurlRetryDelay:=1} --connect-timeout ${CurlConnectTimeout:=5} -sf"
regbin="" regbin=""
jqbin="" jqbin=""
@@ -120,14 +122,21 @@ shift "$((OPTIND-1))"
# Set $1 to a variable for name filtering later # Set $1 to a variable for name filtering later
SearchName="${1:-}" 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"
fi
# Setting up options and sourcing functions # Setting up options and sourcing functions
if [[ "$DontUpdate" == true ]]; then AutoMode=true; fi if [[ "$DontUpdate" == true ]]; then AutoMode=true; fi
if [[ "$MonoMode" == true ]]; then declare c_{red,green,yellow,blue,teal,reset}=""; fi if [[ "$MonoMode" == true ]]; then declare c_{red,green,yellow,blue,teal,reset}=""; fi
if [[ "$Notify" == true ]]; then if [[ "$Notify" == true ]]; then
if [[ -s "${ScriptWorkDir}/notify.sh" ]]; then source_if_exists_or_fail "${ScriptWorkDir}/notify.sh" || source_if_exists_or_fail "${ScriptWorkDir}/notify_templates/notify_v2.sh" || Notify=false
source "${ScriptWorkDir}/notify.sh"
else Notify=false
fi
fi fi
if [[ -n "$Exclude" ]]; then if [[ -n "$Exclude" ]]; then
IFS=',' read -ra Excludes <<< "$Exclude" IFS=',' read -ra Excludes <<< "$Exclude"
@@ -148,15 +157,23 @@ if [[ -n "$CollectorTextFileDirectory" ]]; then
fi fi
fi fi
exec_if_exists() {
if [[ $(type -t $1) == function ]]; then "$@"; fi
}
exec_if_exists_or_fail() {
[[ $(type -t $1) == function ]] && "$@"
}
self_update_curl() { self_update_curl() {
cp "$ScriptPath" "$ScriptPath".bak cp "$ScriptPath" "$ScriptPath".bak
if command -v curl &>/dev/null; then if command -v curl &>/dev/null; then
curl -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" 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 exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
exit 1 # Exit the old instance exit 1 # Exit the old instance
elif command -v wget &>/dev/null; then elif command -v wget &>/dev/null; then
wget $RawUrl -O "$ScriptPath"; chmod +x "$ScriptPath" wget --waitretry=1 --timeout=15 -t 10 $RawUrl -O "$ScriptPath"; chmod +x "$ScriptPath"
printf "\n%b---%b starting over with the updated version %b---%b\n" "$c_yellow" "$c_teal" "$c_yellow" "$c_reset" 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 exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
exit 0 # exit the old instance exit 0 # exit the old instance
@@ -255,8 +272,8 @@ binary_downloader() {
*) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset"; exit 1;; *) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset"; exit 1;;
esac esac
GetUrl="${BinaryUrl/TEMP/"$architecture"}" GetUrl="${BinaryUrl/TEMP/"$architecture"}"
if command -v curl &>/dev/null; then curl -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 "$GetUrl" -O "$ScriptWorkDir/$BinaryName"; 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; else printf "\n%bcurl/wget not available - get %s manually from the repo link, exiting.%b" "$c_red" "$BinaryName" "$c_reset"; exit 1;
fi fi
[[ -f "$ScriptWorkDir/$BinaryName" ]] && chmod +x "$ScriptWorkDir/$BinaryName" [[ -f "$ScriptWorkDir/$BinaryName" ]] && chmod +x "$ScriptWorkDir/$BinaryName"
@@ -270,7 +287,7 @@ distro_checker() {
elif [[ -f /etc/arch-release ]]; then elif [[ -f /etc/arch-release ]]; then
[[ "$isRoot" == true ]] && PkgInstaller="pacman -S" || PkgInstaller="sudo pacman -S" [[ "$isRoot" == true ]] && PkgInstaller="pacman -S" || PkgInstaller="sudo pacman -S"
elif [[ -f /etc/debian_version ]]; then elif [[ -f /etc/debian_version ]]; then
[[ "" == true ]] && PkgInstaller="apt-get install" || PkgInstaller="sudo apt-get install" [[ "$isRoot" == true ]] && PkgInstaller="apt-get install" || PkgInstaller="sudo apt-get install"
elif [[ -f /etc/redhat-release ]]; then elif [[ -f /etc/redhat-release ]]; then
[[ "$isRoot" == true ]] && PkgInstaller="dnf install" || PkgInstaller="sudo dnf install" [[ "$isRoot" == true ]] && PkgInstaller="dnf install" || PkgInstaller="sudo dnf install"
elif [[ -f /etc/SuSE-release ]]; then elif [[ -f /etc/SuSE-release ]]; then
@@ -317,6 +334,9 @@ dependency_check() {
${!AppVar} "$VerFlag" &> /dev/null || { printf "%s\n" "$AppName is not working - try to remove it and re-download it, exiting."; exit 1; } ${!AppVar} "$VerFlag" &> /dev/null || { printf "%s\n" "$AppName is not working - try to remove it and re-download it, exiting."; exit 1; }
} }
dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
dependency_check "jq" "jqbin" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
# Numbered List function # Numbered List function
# if urls.list exists add release note url per line # if urls.list exists add release note url per line
list_options() { list_options() {
@@ -328,19 +348,23 @@ list_options() {
} }
# Version check & initiate self update # Version check & initiate self update
if [[ "$VERSION" != "$LatestRelease" ]]; then 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" 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 if [[ "$AutoMode" == false ]]; then
read -r -p "Would you like to update? y/[n]: " SelfUpdate read -r -p "Would you like to update? y/[n]: " SelfUpdate
[[ "$SelfUpdate" =~ [yY] ]] && self_update [[ "$SelfUpdate" =~ [yY] ]] && self_update
elif [[ "$AutoMode" == true ]] && [[ "$AutoSelfUpdate" == true ]]; then self_update; elif [[ "$AutoMode" == true ]] && [[ "$AutoSelfUpdate" == true ]]; then self_update;
else else
[[ "$Notify" == true ]] && { [[ $(type -t dockcheck_notification) == function ]] && dockcheck_notification "$VERSION" "$LatestRelease" "$LatestChanges" || printf "Could not source notification function.\n"; } [[ "$Notify" == true ]] && { exec_if_exists_or_fail dockcheck_notification "$VERSION" "$LatestRelease" "$LatestChanges" || printf "Could not source notification function.\n"; }
fi fi
fi
else
printf "ERROR: Failed to curl latest Dockcheck.sh release version.\n"
fi fi
dependency_check "regctl" "regbin" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP" # Version check for notify templates
dependency_check "jq" "jqbin" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP" [[ "$Notify" == true ]] && [[ ! -s "${ScriptWorkDir}/notify.sh" ]] && { exec_if_exists_or_fail notify_update_notification || printf "Could not source notify notification function.\n"; }
# Check docker compose binary # Check docker compose binary
docker info &>/dev/null || { printf "\n%bYour current user does not have permissions to the docker socket - may require root / docker group. Exiting.%b\n" "$c_red" "$c_reset"; exit 1; } docker info &>/dev/null || { printf "\n%bYour current user does not have permissions to the docker socket - may require root / docker group. Exiting.%b\n" "$c_red" "$c_reset"; exit 1; }
@@ -402,7 +426,7 @@ check_image() {
# Checking for errors while setting the variable # Checking for errors while setting the variable
if RegHash=$($t_out "$regbin" -v error image digest --list "$RepoUrl" 2>&1); then if RegHash=$($t_out "$regbin" -v error image digest --list "$RepoUrl" 2>&1); then
if [[ "$LocalHash" = *"$RegHash"* ]]; then if [[ "$LocalHash" == *"$RegHash"* ]]; then
printf "%s\n" "NoUpdates $i" printf "%s\n" "NoUpdates $i"
else else
if [[ -n "${DaysOld:-}" ]] && ! datecheck; then if [[ -n "${DaysOld:-}" ]] && ! datecheck; then
@@ -457,11 +481,7 @@ unset IFS
# Run the prometheus exporter function # Run the prometheus exporter function
if [[ -n "${CollectorTextFileDirectory:-}" ]]; then if [[ -n "${CollectorTextFileDirectory:-}" ]]; then
if type -t prometheus_exporter &>/dev/null; then exec_if_exists_or_fail prometheus_exporter ${#NoUpdates[@]} ${#GotUpdates[@]} ${#GotErrors[@]} || printf "%s\n" "Could not source prometheus exporter function."
prometheus_exporter ${#NoUpdates[@]} ${#GotUpdates[@]} ${#GotErrors[@]}
else
printf "%s\n" "Could not source prometheus exporter function."
fi
fi fi
# Define how many updates are available # Define how many updates are available
@@ -481,7 +501,7 @@ if [[ -n ${GotUpdates[*]:-} ]]; then
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset" printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
if [[ -s "$ScriptWorkDir/urls.list" ]] && [[ "$PrintReleaseURL" == true ]]; then releasenotes; else Updates=("${GotUpdates[@]}"); fi if [[ -s "$ScriptWorkDir/urls.list" ]] && [[ "$PrintReleaseURL" == true ]]; then releasenotes; else Updates=("${GotUpdates[@]}"); fi
[[ "$AutoMode" == false ]] && list_options || printf "%s\n" "${Updates[@]}" [[ "$AutoMode" == false ]] && list_options || printf "%s\n" "${Updates[@]}"
[[ "$Notify" == true ]] && { type -t send_notification &>/dev/null && send_notification "${GotUpdates[@]}" || printf "\nCould not source notification function.\n"; } [[ "$Notify" == true ]] && { exec_if_exists_or_fail send_notification "${GotUpdates[@]}" || printf "\nCould not source notification function.\n"; }
fi fi
# Optionally get updates if there's any # Optionally get updates if there's any
@@ -546,7 +566,7 @@ if [[ -n "${GotUpdates:-}" ]]; then
ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels") ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
[[ "$ContRestartStack" == "null" ]] && ContRestartStack="" [[ "$ContRestartStack" == "null" ]] && ContRestartStack=""
ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels") ContOnlySpecific=$($jqbin -r '."mag37.dockcheck.only-specific-container"' <<< "$ContLabels")
[[ "$ContRestartStack" == "null" ]] && ContRestartStack="" [[ "$ContOnlySpecific" == "null" ]] && ContRestartStack=""
# 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" ]] && continue
@@ -554,7 +574,7 @@ if [[ -n "${GotUpdates:-}" ]]; then
# 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; }
## Reformatting path + multi compose ## Reformatting path + multi compose
if [[ $ContConfigFile = '/'* ]]; then if [[ $ContConfigFile == '/'* ]]; then
CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s " "$conf"; done) CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s " "$conf"; done)
else else
CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s/%s " "$ContPath" "$conf"; done) CompleteConfs=$(for conf in ${ContConfigFile//,/ }; do printf -- "-f %s/%s " "$ContPath" "$conf"; done)

View File

@@ -1,11 +1,12 @@
### 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.1" NOTIFY_DSM_VERSION="v0.3"
# INFO: ssmtp is deprecated - consider to use msmtp instead. # 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. # mSMTP/sSMTP has to be installed and configured manually.
# The existing DSM Notification Email configuration will be used automatically. # The existing DSM Notification Email configuration will be used automatically.
# Modify to your liking - changing SendMailTo and Subject and content. # 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 DSM_SENDMAILTO and DSM_SUBJECTTAG in your dockcheck.config file.
MSMTP=$(which msmtp) MSMTP=$(which msmtp)
SSMTP=$(which ssmtp) SSMTP=$(which ssmtp)
@@ -18,18 +19,17 @@ else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
fi fi
FromHost=$(hostname) trigger_DSM_notification() {
trigger_notification() {
CfgFile="/usr/syno/etc/synosmtp.conf" CfgFile="/usr/syno/etc/synosmtp.conf"
# User variables: # User variables:
# Automatically sends to your usual destination for synology DSM notification emails. # Automatically sends to your usual destination for synology DSM notification emails.
# You can also manually override by assigning something else to SendMailTo below. # You can also manually override by assigning something else to DSM_SENDMAILTO in dockcheck.config.
SendMailTo=$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p') SendMailTo=${DSM_SENDMAILTO:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
#SendMailTo="me@mydomain.com" # e.g. DSM_SENDMAILTO="me@mydomain.com"
SubjectTag=$(grep 'eventsubjectprefix' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p') SubjectTag=${DSM_SUBJECTTAG:-$(grep 'eventsubjectprefix' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
# e.g. DSM_SUBJECTTAG="Email Subject Prefix"
SenderName=$(grep 'smtp_from_name' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p') SenderName=$(grep 'smtp_from_name' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
SenderMail=$(grep 'smtp_from_mail' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p') SenderMail=$(grep 'smtp_from_mail' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')
SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')} SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)".*/\1/p')}
@@ -38,45 +38,18 @@ $MailPkg $SendMailTo << __EOF
From: "$SenderName" <$SenderMail> From: "$SenderName" <$SenderMail>
date:$(date -R) date:$(date -R)
To: <$SendMailTo> To: <$SendMailTo>
Subject: $SubjectTag $MessageTitle $FromHost Subject: $SubjectTag $MessageTitle
Content-Type: text/plain; charset=UTF-8; format=flowed Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit
$MessageBody $MessageBody
From $SenderName From $SenderName
__EOF __EOF
if [[ $? -gt 0 ]]; then
NotifyError=true
fi
# This ensures DSM's container manager will also see the update # This ensures DSM's container manager will also see the update
/var/packages/ContainerManager/target/tool/image_upgradable_checker /var/packages/ContainerManager/target/tool/image_upgradable_checker
} }
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending email notification.\n"
MessageTitle="Updates available on"
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending email dockcheck notification.\n"
MessageTitle="New version of dockcheck available on"
# 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
}

View File

@@ -1,55 +1,40 @@
### 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_APPRISE_VERSION="v0.1" NOTIFY_APPRISE_VERSION="v0.3"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Modify to fit your setup - if API, set AppriseURL to your Apprise ip/domain. # 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 APPRISE_PAYLOAD in your dockcheck.config file.
# If API, set APPRISE_URL instead.
FromHost=$(hostname) if [[ -z "${APPRISE_PAYLOAD:-}" ]] && [[ -z "${APPRISE_URL:-}" ]]; then
printf "Apprise notification channel enabled, but required configuration variables are missing. Apprise notifications will not be sent.\n"
trigger_notification() { remove_channel apprise
fi
### Modify to fit your setup: trigger_apprise_notification() {
if [[ -n "${APPRISE_PAYLOAD:-}" ]]; then
apprise -vv -t "$MessageTitle" -b "$MessageBody" \ apprise -vv -t "$MessageTitle" -b "$MessageBody" \
mailto://myemail:mypass@gmail.com \ ${APPRISE_PAYLOAD}
mastodons://{token}@{host} \
pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b \
tgram://{bot_token}/{chat_id}/
### If you use the Apprise-API - Comment out the apprise command above. if [[ $? -gt 0 ]]; then
### Uncomment the AppriseURL and the curl-line below: NotifyError=true
# AppriseURL="http://apprise.mydomain.tld:1234/notify/apprise" fi
# curl -X POST -F "title=$MessageTitle" -F "body=$MessageBody" -F "tags=all" $AppriseURL
}
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending Apprise notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### 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 fi
trigger_notification # e.g. APPRISE_PAYLOAD='mailto://myemail:mypass@gmail.com
# mastodons://{token}@{host}
# pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b
# tgram://{bot_token}/{chat_id}/'
if [[ -n "${APPRISE_URL:-}" ]]; then
AppriseURL="${APPRISE_URL}"
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
} }

View File

@@ -1,43 +1,28 @@
### 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_DISCORD_VERSION="v0.1" NOTIFY_DISCORD_VERSION="v0.4"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Modify to fit your setup - set DiscordWebhookUrl # 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 DISCORD_WEBHOOK_URL in your dockcheck.config file.
FromHost=$(hostname) if [[ -z "${DISCORD_WEBHOOK_URL:-}" ]]; then
printf "Discord notification channel enabled, but required configuration variables are missing. Discord notifications will not be sent.\n"
trigger_notification() { remove_channel discord
# Modify to fit your setup: fi
DiscordWebhookUrl="PasteYourFullDiscordWebhookURL"
MsgBody="{\"username\":\"$FromHost\",\"content\":\"$MessageBody\"}" trigger_discord_notification() {
curl -sS -o /dev/null --fail -X POST -H "Content-Type: application/json" -d "$MsgBody" "$DiscordWebhookUrl" DiscordWebhookUrl="${DISCORD_WEBHOOK_URL}" # e.g. DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/<token string>
}
send_notification() { JsonData=$( "$jqbin" -n \
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") --arg username "$FromHost" \
UpdToString=$( printf '%s\\n' "${Updates[@]}" ) --arg body "$MessageBody" \
'{"username": $username, "content": $body}' )
printf "\nSending Discord notification\n" curl -S -o /dev/null ${CurlArgs} -X POST -H "Content-Type: application/json" -d "$JsonData" "$DiscordWebhookUrl"
# Setting the MessageBody variable here.
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
trigger_notification if [[ $? -gt 0 ]]; then
} NotifyError=true
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
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 fi
trigger_notification
} }

View File

@@ -1,44 +1,9 @@
### 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_GENERIC_VERSION="v0.1" NOTIFY_GENERIC_VERSION="v0.2"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# generic sample, the "Hello World" of notification addons # generic sample, the "Hello World" of notification addons
FromHost=$(hostname) trigger_generic_notification() {
trigger_notification() {
# Modify to fit your setup:
printf "\n$MessageTitle\n" printf "\n$MessageTitle\n"
printf "\n$MessageBody\n" printf "\n$MessageBody\n"
} }
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
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### 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
}

View File

@@ -1,16 +1,20 @@
### 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_GOTIFY_VERSION="v0.2" NOTIFY_GOTIFY_VERSION="v0.4"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Modify to fit your setup - set GotifyUrl and GotifyToken. # 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 GOTIFY_TOKEN and GOTIFY_DOMAIN in your dockcheck.config file.
FromHost=$(hostname) if [[ -z "${GOTIFY_TOKEN:-}" ]] || [[ -z "${GOTIFY_DOMAIN:-}" ]]; then
printf "Gotify notification channel enabled, but required configuration variables are missing. Gotify notifications will not be sent.\n"
trigger_notification() { remove_channel gotify
# Modify to fit your setup: fi
GotifyToken="Your Gotify token here"
GotifyUrl="https://api.gotify/message?token=${GotifyToken}" trigger_gotify_notification() {
GotifyToken="${GOTIFY_TOKEN}" # e.g. GOTIFY_TOKEN=token-value
GotifyUrl="${GOTIFY_DOMAIN}/message?token=${GotifyToken}" # e.g. GOTIFY_URL=https://gotify.domain.tld
if [[ "$PrintMarkdownURL" == true ]]; then if [[ "$PrintMarkdownURL" == true ]]; then
ContentType="text/markdown" ContentType="text/markdown"
@@ -18,44 +22,15 @@ trigger_notification() {
ContentType="text/plain" ContentType="text/plain"
fi fi
JsonData=$( jq -n \ JsonData=$( "$jqbin" -n \
--arg body "$MessageBody" \ --arg body "$MessageBody" \
--arg title "$MessageTitle" \ --arg title "$MessageTitle" \
--arg type "$ContentType" \ --arg type "$ContentType" \
'{message: $body, title: $title, priority: 5, extras: {"client::display": {"contentType": $type}}}' ) '{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
}
send_notification() { if [[ $? -gt 0 ]]; then
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") NotifyError=true
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
printf "\nSending Gotify notification\n"
# Setting the MessageTitle and MessageBody variable here.
MessageTitle="${FromHost} - updates available."
printf -v MessageBody "Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending Gotify 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_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 fi
trigger_notification
} }

View File

@@ -1,51 +1,27 @@
### 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_MATRIX_VERSION="v0.1" NOTIFY_MATRIX_VERSION="v0.3"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Modify to fit your setup - set MatrixServer, Room_id and AccessToken # 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 MATRIX_ACCESS_TOKEN, MATRIX_ROOM_ID, and MATRIX_SERVER_URL in your dockcheck.config file.
FromHost=$(hostname) if [[ -z "${MATRIX_ACCESS_TOKEN:-}" ]] || [[ -z "${MATRIX_ROOM_ID}:-" ]] || [[ -z "${MATRIX_SERVER_URL}:-" ]]; then
printf "Matrix notification channel enabled, but required configuration variables are missing. Matrix notifications will not be sent.\n"
trigger_notification() { remove_channel matrix
# Modify to fit your setup: fi
AccessToken="Your Matrix token here"
Room_id="Enter Room_id here" trigger_matrix_notification() {
MatrixServer="Enter Your HomeServer URL" AccessToken="${MATRIX_ACCESS_TOKEN}" # e.g. MATRIX_ACCESS_TOKEN=token-value
Room_id="${MATRIX_ROOM_ID}" # e.g. MATRIX_ROOM_ID=myroom
MatrixServer="${MATRIX_SERVER_URL}" # e.g. MATRIX_SERVER_URL=http://matrix.yourdomain.tld
MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}" 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 # 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"
}
send_notification() { if [[ $? -gt 0 ]]; then
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") NotifyError=true
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
printf "\nSending Matrix notification\n"
# Setting the MessageBody variable here.
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### 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 fi
trigger_notification
} }

View File

@@ -1,57 +0,0 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
NOTIFY_NTFYSH_VERSION="v0.2"
#
# Copy/rename this file to notify.sh to enable the notification snippet.
# Setup app and subscription at https://ntfy.sh
# Use your unique Topic Name in the URL below.
FromHost=$(hostname)
trigger_notification() {
# Modify to fit your setup:
NtfyUrl="ntfy.sh/YourUniqueTopicName"
if [[ "$PrintMarkdownURL" == true ]]; then
ContentType="Markdown: yes"
else
ContentType="Markdown: no" #text/plain
fi
curl -sS -o /dev/null --show-error --fail \
-H "Title: $MessageTitle" \
-H "$ContentType" \
-d "$MessageBody" \
"$NtfyUrl"
}
send_notification() {
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending ntfy.sh notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### 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
}

View File

@@ -0,0 +1,36 @@
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
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.
# 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 NTFY_DOMAIN and NTFY_TOPIC_NAME in your dockcheck.config file.
if [[ -z "${NTFY_DOMAIN:-}" ]] || [[ -z "${NTFY_TOPIC_NAME:-}" ]]; then
printf "Ntfy notification channel enabled, but required configuration variables are missing. Ntfy notifications will not be sent.\n"
remove_channel ntfy
fi
trigger_ntfy_notification() {
NtfyUrl="${NTFY_DOMAIN}/${NTFY_TOPIC_NAME}"
# e.g.
# NTFY_DOMAIN=ntfy.sh
# NTFY_TOPIC_NAME=YourUniqueTopicName
if [[ "$PrintMarkdownURL" == true ]]; then
ContentType="Markdown: yes"
else
ContentType="Markdown: no" #text/plain
fi
curl -S -o /dev/null ${CurlArgs} \
-H "Title: $MessageTitle" \
-H "$ContentType" \
-d "$MessageBody" \
"$NtfyUrl"
if [[ $? -gt 0 ]]; then
NotifyError=true
fi
}

View File

@@ -1,51 +1,26 @@
### 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_PUSHBULLET_VERSION="v0.1" NOTIFY_PUSHBULLET_VERSION="v0.3"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Requires jq installed and in PATH. # Requires jq installed and in PATH.
# Modify to fit your setup - set Url and 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 PUSHBULLET_TOKEN and PUSHBULLET_URL in your dockcheck.config file.
FromHost=$(hostname) if [[ -z "${PUSHBULLET_URL:-}" ]] || [[ -z "${PUSHBULLET_TOKEN:-}" ]]; then
printf "Pushbullet notification channel enabled, but required configuration variables are missing. Pushbullet notifications will not be sent.\n"
trigger_notification() { remove_channel pushbullet
# Modify to fit your setup: fi
PushUrl="https://api.pushbullet.com/v2/pushes"
PushToken="Your Pushbullet token here" trigger_pushbullet_notification() {
PushUrl="${PUSHBULLET_URL}" # e.g. PUSHBULLET_URL=https://api.pushbullet.com/v2/pushes
PushToken="${PUSHBULLET_TOKEN}" # e.g. PUSHBULLET_TOKEN=token-value
# Requires jq to process json data # Requires jq to process json data
jq -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 @-
}
send_notification() { if [[ $? -gt 0 ]]; then
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") NotifyError=true
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
printf "\nSending pushbullet notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending pushbullet 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_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 fi
trigger_notification
} }

View File

@@ -1,57 +1,32 @@
### 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_PUSHOVER_VERSION="v0.1" NOTIFY_PUSHOVER_VERSION="v0.3"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Requires jq installed and in PATH. # Requires jq installed and in PATH.
# Modify to fit your setup - set Url and 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 PUSHOVER_USER_KEY, PUSHOVER_TOKEN, and PUSHOVER_URL in your dockcheck.config file.
FromHost=$(hostname) if [[ -z "${PUSHOVER_URL:-}" ]] || [[ -z "${PUSHOVER_USER_KEY:-}" ]] || [[ -z "${PUSHOVER_TOKEN:-}" ]]; then
printf "Pushover notification channel enabled, but required configuration variables are missing. Pushover notifications will not be sent.\n"
trigger_notification() { remove_channel pushover
# Modify to fit your setup: fi
PushoverUrl="https://api.pushover.net/1/messages.json"
PushoverUserKey="Your Pushover User Key Here" trigger_pushover_notification() {
PushoverToken="Your Pushover API Token Here" PushoverUrl="${PUSHOVER_URL}" # e.g. PUSHOVER_URL=https://api.pushover.net/1/messages.json
PushoverUserKey="${PUSHOVER_USER_KEY}" # e.g. PUSHOVER_USER_KEY=userkey
PushoverToken="${PUSHOVER_TOKEN}" # e.g. PUSHOVER_TOKEN=token-value
# Sending the notification via Pushover # 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 "token=$PushoverToken" \
-F "user=$PushoverUserKey" \ -F "user=$PushoverUserKey" \
-F "title=$MessageTitle" \ -F "title=$MessageTitle" \
-F "message=$MessageBody" \ -F "message=$MessageBody" \
$PushoverUrl $PushoverUrl
}
send_notification() { if [[ $? -gt 0 ]]; then
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") NotifyError=true
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here
printf "\nSending pushover notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### 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 fi
trigger_notification
} }

View File

@@ -1,52 +1,28 @@
### 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_SLACK_VERSION="v0.1" NOTIFY_SLACK_VERSION="v0.3"
# #
# Copy/rename this file to notify.sh in the same directory as dockcheck.sh to enable the notification snippet. # Setup app and token at https://api.slack.com/tutorials/tracks/posting-messages-with-curl
# Setu 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.
# Add your AccessToken and ChannelID below # 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 SLACK_ACCESS_TOKEN, and SLACK_CHANNEL_ID in your dockcheck.config file.
FromHost=$(hostname) if [[ -z "${SLACK_ACCESS_TOKEN:-}" ]] || [[ -z "${SLACK_CHANNEL_ID:-}" ]]; then
printf "Slack notification channel enabled, but required configuration variables are missing. Slack notifications will not be sent.\n"
trigger_notification() { remove_channel slack
# Modify to fit your setup: fi
AccessToken="xoxb-not-a-real-token-this-will-not-work"
ChannelID="C123456" trigger_slack_notification() {
AccessToken="${SLACK_ACCESS_TOKEN}" # e.g. SLACK_ACCESS_TOKEN=some-token
ChannelID="${SLACK_CHANNEL_ID}" # e.g. CHANNEL_ID=mychannel
SlackUrl="https://slack.com/api/chat.postMessage" 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" \ -d "text=$MessageBody" -d "channel=$ChannelID" \
-H "Authorization: Bearer $AccessToken" \ -H "Authorization: Bearer $AccessToken" \
-X POST $SlackUrl -X POST $SlackUrl
}
send_notification() { if [[ $? -gt 0 ]]; then
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") NotifyError=true
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending Slack notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending Slack 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_slack.sh"
LatestNotifyRelease="$(curl -s -r 0-150 $RawNotifyUrl | sed -n "/NOTIFY_SLACK_VERSION/s/NOTIFY_SLACK_VERSION=//p" | tr -d '"')"
if [[ "$NOTIFY_SLACK_VERSION" != "$LatestNotifyRelease" ]] ; then
printf -v NotifyUpdate "\n\nnotify_slack.sh update avialable:\n $NOTIFY_SLACK_VERSION -> $LatestNotifyRelease\n"
MessageBody="${MessageBody}${NotifyUpdate}"
fi fi
trigger_notification
} }

View File

@@ -1,10 +1,17 @@
### 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.1" NOTIFY_SMTP_VERSION="v0.3"
# INFO: ssmtp is depcerated - consider to use msmtp instead. # INFO: ssmtp is depcerated - 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. # mSMTP/sSMTP has to be installed and configured manually.
# Modify to fit your setup - changing SendMailFrom, SendMailTo, SubjectTag # 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 SMTP_MAIL_FROM, SMTP_MAIL_TO, and SMTP_SUBJECT_TAG in your dockcheck.config file.
if [[ -z "${SMTP_MAIL_FROM:-}" ]] || [[ -z "${SMTP_MAIL_TO:-}" ]] || [[ -z "${SMTP_SUBJECT_TAG:-}" ]]; then
printf "SMTP notification channel enabled, but required configuration variables are missing. SMTP notifications will not be sent.\n"
remove_channel smtp
fi
MSMTP=$(which msmtp) MSMTP=$(which msmtp)
SSMTP=$(which ssmtp) SSMTP=$(which ssmtp)
@@ -17,13 +24,10 @@ else
echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1
fi fi
FromHost=$(hostname) trigger_smtp_notification() {
SendMailFrom="${SMTP_MAIL_FROM}" # e.g. MAIL_FROM=me@mydomain.tld
trigger_notification() { SendMailTo="${SMTP_MAIL_TO}" # e.g. MAIL_TO=me@mydomain.tld
# User variables: SubjectTag="${SMTP_SUBJECT_TAG}" # e.g. SUBJECT_TAG=dockcheck
SendMailFrom="me@mydomain.tld"
SendMailTo="me@mydomain.tld"
SubjectTag="dockcheck"
$MailPkg $SendMailTo << __EOF $MailPkg $SendMailTo << __EOF
From: "$FromHost" <$SendMailFrom> From: "$FromHost" <$SendMailFrom>
@@ -36,36 +40,8 @@ Content-Transfer-Encoding: 7bit
$MessageBody $MessageBody
__EOF __EOF
}
if [[ $? -gt 0 ]]; then
send_notification() { NotifyError=true
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@") fi
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
printf "\nSending email notification.\n"
MessageTitle="Updates available on"
# Setting the MessageBody variable here.
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n\n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### to not send notifications when dockcheck itself has updates.
dockcheck_notification() {
printf "\nSending email dockcheck notification.\n"
MessageTitle="New version of dockcheck available on"
# 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
} }

View File

@@ -1,58 +1,39 @@
### 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_TELEGRAM_VERSION="v0.1" NOTIFY_TELEGRAM_VERSION="v0.4"
# #
# Copy/rename this file to notify.sh to enable the notification snippet.
# Required receiving services must already be set up. # Required receiving services must already be set up.
# Modify to fit your setup - set TelegramChatId and TelegramToken. # 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 TELEGRAM_CHAT_ID and TELEGRAM_TOKEN in your dockcheck.config file.
FromHost=$(hostname) if [[ -z "${TELEGRAM_CHAT_ID:-}" ]] || [[ -z "${TELEGRAM_TOKEN:-}" ]]; then
printf "Telegram notification channel enabled, but required configuration variables are missing. Telegram notifications will not be sent.\n"
trigger_notification() { remove_channel telegram
fi
trigger_telegram_notification() {
if [[ "$PrintMarkdownURL" == true ]]; then if [[ "$PrintMarkdownURL" == true ]]; then
ParseMode="Markdown" ParseMode="Markdown"
else else
ParseMode="HTML" ParseMode="HTML"
fi fi
# Modify to fit your setup: TelegramToken="${TELEGRAM_TOKEN}" # e.g. TELEGRAM_TOKEN=token-value
TelegramToken="Your Telegram token here" TelegramChatId="${TELEGRAM_CHAT_ID}" # e.g. TELEGRAM_CHAT_ID=mychatid
TelegramChatId="Your Telegram ChatId here"
TelegramUrl="https://api.telegram.org/bot$TelegramToken" TelegramUrl="https://api.telegram.org/bot$TelegramToken"
TelegramTopicID=12345678 ## Set to 0 if not using specific topic within chat TelegramTopicID=${TELEGRAM_TOPIC_ID:="0"}
TelegramData="{\"chat_id\":\"$TelegramChatId\",\"text\":\"$MessageBody\",\"message_thread_id\":\"$TelegramTopicID\",\"disable_notification\": false}"
curl -sS -o /dev/null --fail -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$TelegramData" JsonData=$( "$jqbin" -n \
} --arg chatid "$TelegramChatId" \
--arg text "$MessageBody" \
--arg thread "$TelegramTopicID" \
--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}' )
send_notification() { curl -S -o /dev/null ${CurlArgs} -X POST "$TelegramUrl/sendMessage" -H 'Content-Type: application/json' -d "$JsonData"
[ -s "$ScriptWorkDir"/urls.list ] && releasenotes || Updates=("$@")
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
# platform specific notification code would go here if [[ $? -gt 0 ]]; then
printf "\nSending Telegram notification\n" NotifyError=true
# Setting the MessageBody variable here.
MessageBody="🐋 Containers on $FromHost with updates available: \n$UpdToString"
trigger_notification
}
### Rename (eg. disabled_dockcheck_notification), remove or comment out the following function
### 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 fi
trigger_notification
} }

View File

@@ -0,0 +1,258 @@
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 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
[[ "${channel}" != "$1" ]] && temp_array+=("${channel}")
done
enabled_notify_channels=( "${temp_array[@]}" )
}
for channel in "${enabled_notify_channels[@]}"; do
source_if_exists_or_fail "${ScriptWorkDir}/notify_${channel}.sh" || \
source_if_exists_or_fail "${ScriptWorkDir}/notify_templates/notify_${channel}.sh" || \
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=("$@")
if [[ -n "${snooze}" ]] && [[ -f "${SnoozeFile}" ]]; then
UpdNotifyCount=$(notify_containers_count "${Updates[@]}")
else
UpdNotifyCount="${#Updates[@]}"
fi
NotifyError=false
if [[ "${UpdNotifyCount}" -gt 0 ]]; then
UpdToString=$( printf '%s\\n' "${Updates[@]}" )
UpdToString=${UpdToString%\\n}
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
DockcheckNotify=false
NotifyError=false
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
NotifyUpdateNotify=false
NotifyError=false
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_${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
}

View File

@@ -1,49 +1,75 @@
# This is a list of container names and releasenote urls, separated by space.
# Modify, add and (if necessary) remove to fit your needs.
# Additions are welcome! Append your list to the git-repo, use generic names and sensible urls. # Additions are welcome! Append your list to the git-repo, use generic names and sensible urls.
# Modify, add and (if necessary) remove to fit your needs.
# This is a list of container names and releasenote urls, separated by space.
apprise-api https://github.com/linuxserver/docker-apprise-api/releases
homer https://github.com/bastienwirtz/homer/releases
nginx https://github.com/docker-library/official-images/blob/master/library/nginx
vaultwarden-server https://github.com/dani-garcia/vaultwarden/releases
bruceforce-vaultwarden-backup https://github.com/Bruceforce/vaultwarden-backup/blob/main/CHANGELOG.md
actual_server https://actualbudget.org/blog actual_server https://actualbudget.org/blog
gotify https://github.com/gotify/server/releases apprise-api https://github.com/linuxserver/docker-apprise-api/releases
traefik https://github.com/traefik/traefik/releases
caddy https://github.com/caddyserver/caddy/releases
homarr https://github.com/homarr-labs/homarr/releases
dozzle https://github.com/amir20/dozzle/releases
beszel https://github.com/henrygd/beszel/releases
forgejo https://codeberg.org/forgejo/forgejo/releases
dockge https://github.com/louislam/dockge/releases
cup https://github.com/sergi0g/cup/releases
calibre https://github.com/linuxserver/docker-calibre/releases
calibre-web https://github.com/linuxserver/docker-calibre-web/releases
readarr https://github.com/Readarr/Readarr/releases
audiobookshelf https://github.com/advplyr/audiobookshelf/releases audiobookshelf https://github.com/advplyr/audiobookshelf/releases
gluetun https://github.com/qdm12/gluetun/releases
bazarr https://github.com/morpheus65535/bazarr/releases bazarr https://github.com/morpheus65535/bazarr/releases
bazarr-ls https://github.com/linuxserver/docker-bazarr/releases bazarr-ls https://github.com/linuxserver/docker-bazarr/releases
beszel https://github.com/henrygd/beszel/releases
bookstack https://github.com/BookStackApp/BookStack/releases
bruceforce-vaultwarden-backup https://github.com/Bruceforce/vaultwarden-backup/blob/main/CHANGELOG.md
caddy https://github.com/caddyserver/caddy/releases
calibre https://github.com/linuxserver/docker-calibre/releases
calibre-web https://github.com/linuxserver/docker-calibre-web/releases
cleanuperr https://github.com/flmorg/cleanuperr/releases
cross-seed https://github.com/cross-seed/cross-seed/releases
cup https://github.com/sergi0g/cup/releases
dockge https://github.com/louislam/dockge/releases
dozzle https://github.com/amir20/dozzle/releases
flatnotes https://github.com/dullage/flatnotes/releases
forgejo https://codeberg.org/forgejo/forgejo/releases
fressrss https://github.com/FreshRSS/FreshRSS/releases
gluetun https://github.com/qdm12/gluetun/releases
go2rtc https://github.com/AlexxIT/go2rtc/releases
gotify https://github.com/gotify/server/releases
hbbr https://github.com/rustdesk/rustdesk-server/releases
hbbs https://github.com/rustdesk/rustdesk-server/releases
homarr https://github.com/homarr-labs/homarr/releases
home-assistant https://github.com/home-assistant/core/releases/
homer https://github.com/bastienwirtz/homer/releases
immich_machine_learning https://github.com/immich-app/immich/releases
immich_postgres https://github.com/tensorchord/VectorChord/releases
immich_redis https://github.com/valkey-io/valkey/releases
immich_server https://github.com/immich-app/immich/releases
jellyfin https://github.com/jellyfin/jellyfin/releases
jellyseerr https://github.com/Fallenbagel/jellyseerr/releases
jellystat https://github.com/CyferShepard/Jellystat/releases
librespeed https://github.com/librespeed/speedtest/releases
lidarr https://github.com/Lidarr/Lidarr/releases/
lidarr-ls https://github.com/linuxserver/docker-lidarr/releases
lubelogger https://github.com/hargata/lubelog/releases
mattermost https://github.com/mattermost/mattermost/releases
mealie https://github.com/mealie-recipes/mealie/releases
meilisearch https://github.com/meilisearch/meilisearch/releases
monica https://github.com/monicahq/monica/releases
mqtt https://github.com/eclipse/mosquitto/tags
nextcloud-aio-mastercontainer https://github.com/nextcloud/all-in-one/releases
nginx https://github.com/docker-library/official-images/blob/master/library/nginx
owncast https://github.com/owncast/owncast/releases
prowlarr https://github.com/Prowlarr/Prowlarr/releases prowlarr https://github.com/Prowlarr/Prowlarr/releases
prowlarr-ls https://github.com/linuxserver/docker-prowlarr/releases prowlarr-ls https://github.com/linuxserver/docker-prowlarr/releases
qbittorrent https://www.qbittorrent.org/news
qbittorrent-nox https://www.qbittorrent.org/news
radarr https://github.com/Radarr/Radarr/releases/
radarr-ls https://github.com/linuxserver/docker-radarr/releases
readarr https://github.com/Readarr/Readarr/releases
readeck https://codeberg.org/readeck/readeck/releases
recyclarr https://github.com/recyclarr/recyclarr/releases recyclarr https://github.com/recyclarr/recyclarr/releases
roundcubemail https://github.com/roundcube/roundcubemail/releases
sabnzbd https://github.com/linuxserver/docker-sabnzbd/releases sabnzbd https://github.com/linuxserver/docker-sabnzbd/releases
sonarr https://github.com/linuxserver/docker-sonarr/releases scrutiny https://github.com/AnalogJ/scrutiny/releases
radarr https://github.com/linuxserver/docker-radarr/releases sftpgo https://github.com/drakkan/sftpgo/releases
lidarr https://github.com/linuxserver/docker-lidarr/releases
jellyseerr https://github.com/Fallenbagel/jellyseerr/releases
jellyfin https://github.com/jellyfin/jellyfin/releases
tautulli https://github.com/Tautulli/Tautulli/releases
cleanuperr https://github.com/flmorg/cleanuperr/releases
slskd https://github.com/slskd/slskd/releases slskd https://github.com/slskd/slskd/releases
snappymail https://github.com/the-djmaze/snappymail/releases
home-assistant https://github.com/home-assistant/docker/releases sonarr https://github.com/Sonarr/Sonarr/releases/
sonarr-ls https://github.com/linuxserver/docker-sonarr/releases
syncthing https://github.com/syncthing/syncthing/releases
tautulli https://github.com/Tautulli/Tautulli/releases
thelounge https://github.com/thelounge/thelounge/releases
traefik https://github.com/traefik/traefik/releases
vaultwarden-server https://github.com/dani-garcia/vaultwarden/releases
watchtower https://github.com/beatkind/watchtower/releases
wud https://github.com/getwud/wud/releases
zigbee2mqtt https://github.com/Koenkk/zigbee2mqtt/releases zigbee2mqtt https://github.com/Koenkk/zigbee2mqtt/releases
mqtt https://github.com/eclipse/mosquitto/tags
bookstack https://github.com/BookStackApp/BookStack/releases
lubelogger https://github.com/hargata/lubelog/releases
mealie https://github.com/mealie-recipes/mealie/releases
flatnotes https://github.com/dullage/flatnotes/releases