2024-01-05 20:42:53 +01:00
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
2025-09-15 05:25:23 -04:00
NOTIFY_APPRISE_VERSION = "v0.4"
2024-01-05 20:42:53 +01:00
#
# Required receiving services must already be set up.
2025-05-29 16:43:34 -04:00
# 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.
2025-05-25 12:26:13 -04:00
# If API, set APPRISE_URL instead.
2024-01-05 20:42:53 +01:00
2025-09-15 05:25:23 -04:00
trigger_apprise_notification( ) {
if [ [ -n " $1 " ] ] ; then
apprise_channel = " $1 "
else
apprise_channel = "apprise"
fi
2024-01-05 20:42:53 +01:00
2025-09-15 05:25:23 -04:00
UpperChannel = " ${ apprise_channel ^^ } "
2024-01-06 20:33:21 +01:00
2025-09-15 05:25:23 -04:00
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
2025-02-09 22:01:08 +01:00
2025-09-15 05:25:23 -04:00
if [ [ -n " ${ !ApprisePayloadVar :- } " ] ] ; then
2025-05-25 12:26:13 -04:00
apprise -vv -t " $MessageTitle " -b " $MessageBody " \
2025-09-15 05:25:23 -04:00
${ !ApprisePayloadVar }
2025-06-24 09:16:48 -04:00
if [ [ $? -gt 0 ] ] ; then
NotifyError = true
fi
2025-05-25 12:26:13 -04:00
fi
2025-02-07 20:47:01 +01:00
2025-05-25 12:26:13 -04:00
# e.g. APPRISE_PAYLOAD='mailto://myemail:mypass@gmail.com
# mastodons://{token}@{host}
# pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b
# tgram://{bot_token}/{chat_id}/'
2025-02-07 20:47:01 +01:00
2025-09-15 05:25:23 -04:00
if [ [ -n " ${ !AppriseUrlVar :- } " ] ] ; then
AppriseURL = " ${ !AppriseUrlVar } "
2025-06-24 09:16:48 -04:00
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
2025-05-25 12:26:13 -04:00
fi
}