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>
This commit is contained in:
vorezal 2025-05-25 12:26:13 -04:00 committed by GitHub
parent e4b93d113c
commit c63e2441fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 366 additions and 564 deletions

View file

@ -20,6 +20,12 @@
___
## :bell: Changelog
- **v0.6.5**: Refactored notification logic. See notify_templates/notify_v2.sh for upgrade steps.
- Added helper functions to simplify sourcing files and executing functions if they exist.
- Created notify_v2.sh wrapper script.
- Simplified and consolidated notification logic within notify_v2.sh.
- Added support for notification management via environment variables.
- Moved notification secrets to dockcheck.config.
- **v0.6.4**: Restructured the update process - first pulls all updates, then recreates all containers.
- Added logic to skip update check on non-compose containers (unless `-r` option).
- Added option `-F` to revert to `compose up -d <ContainerName>` targeting specific container and not the stack.
@ -126,11 +132,22 @@ Alternatively create an alias where specific flags and values are set.
Example `alias dc=dockcheck.sh -p -x 10 -t 3`.
## :loudspeaker: Notifications
Trigger with the `-i` flag if `notify.sh` is present and configured.
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!
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.
Run it scheduled with `-ni` to only get notified when there's updates available!
V2 installation and configuration (tag v0.6.5 or later):
Remove or rename `notify.sh` if previously configured using the legacy method.
Uncomment and set the NOTIFY_CHANNELS environment variable in `dockcheck.config` to a space separated string of your desired notification channels to enable.
Uncomment and set the environment variables related to the enabled notification channels.
It is recommended not to make changes directly to the `notify_X.sh` template files and to use only environment variables defined in `dockcheck.config` using this method.
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)
Use a `notify_X.sh` template file from the **notify_templates** directory, copy it to `notify.sh` alongside the script, modify it to your needs! (notify.sh is added to .gitignore)
**Current templates:**
- 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))