mirror of
https://github.com/mag37/dockcheck.git
synced 2026-03-05 08:30:35 +01:00
Add file notification channel (#222)
* Add file notification channel * Bypass file channel notifications for dockcheck.sh script * Implement notification channel template reuse and advanced configuration variables. * Fix text insertion formatting for dockcheck script and container updates. * Fix dockcheck.sh notification csv and text output. * Fix ntfy variable references and replace tr for uppercase conversion. * Fix ALLOWEMPTY logic, undefined snippet case, and README formatting. * Refactor notification send/skip logic. Adjust missing variable return codes. * Adjust notifications README section for clarity and readability. --------- Co-authored-by: Matthew Oleksowicz <matt@everyoneneeds.it>
This commit is contained in:
parent
37f33d7a06
commit
31a45f1d84
18 changed files with 620 additions and 267 deletions
|
|
@ -1,5 +1,5 @@
|
|||
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
||||
NOTIFY_APPRISE_VERSION="v0.3"
|
||||
NOTIFY_APPRISE_VERSION="v0.4"
|
||||
#
|
||||
# Required receiving services must already be set up.
|
||||
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
|
||||
|
|
@ -7,17 +7,28 @@ NOTIFY_APPRISE_VERSION="v0.3"
|
|||
# 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.
|
||||
|
||||
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"
|
||||
|
||||
remove_channel apprise
|
||||
fi
|
||||
|
||||
trigger_apprise_notification() {
|
||||
if [[ -n "$1" ]]; then
|
||||
apprise_channel="$1"
|
||||
else
|
||||
apprise_channel="apprise"
|
||||
fi
|
||||
|
||||
if [[ -n "${APPRISE_PAYLOAD:-}" ]]; then
|
||||
UpperChannel="${apprise_channel^^}"
|
||||
|
||||
ApprisePayloadVar="${UpperChannel}_PAYLOAD"
|
||||
AppriseUrlVar="${UpperChannel}_URL"
|
||||
|
||||
if [[ -z "${!ApprisePayloadVar:-}" ]] && [[ -z "${!AppriseUrlVar:-}" ]]; then
|
||||
printf "The ${apprise_channel} notification channel is enabled, but required configuration variables are missing. Apprise notifications will not be sent.\n"
|
||||
|
||||
remove_channel apprise
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -n "${!ApprisePayloadVar:-}" ]]; then
|
||||
apprise -vv -t "$MessageTitle" -b "$MessageBody" \
|
||||
${APPRISE_PAYLOAD}
|
||||
${!ApprisePayloadVar}
|
||||
|
||||
if [[ $? -gt 0 ]]; then
|
||||
NotifyError=true
|
||||
|
|
@ -29,8 +40,8 @@ trigger_apprise_notification() {
|
|||
# pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b
|
||||
# tgram://{bot_token}/{chat_id}/'
|
||||
|
||||
if [[ -n "${APPRISE_URL:-}" ]]; then
|
||||
AppriseURL="${APPRISE_URL}"
|
||||
if [[ -n "${!AppriseUrlVar:-}" ]]; then
|
||||
AppriseURL="${!AppriseUrlVar}"
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue