Ntfy.sh and authentication (#220)

* default.config: add NtfyAuth=

* notify_templates/notify_ntfy.sh: implement NtfyAuth

---------

Co-authored-by: Lat <lat@mail.com>
Co-authored-by: mag37 <robin.ivehult@gmail.com>
This commit is contained in:
op4lat 2025-08-11 15:16:38 -04:00 committed by GitHub
parent fbc9a252f5
commit 9156cc44e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -68,6 +68,7 @@
## https://ntfy.sh or your custom domain with https:// and no trailing /
# NTFY_DOMAIN="https://ntfy.sh"
# NTFY_TOPIC_NAME="YourUniqueTopicName"
# NTFY_AUTH="" # set to either format -> "user:password" OR ":tk_12345678". If using tokens, don't forget the ":"
#
# PUSHBULLET_URL="https://api.pushbullet.com/v2/pushes"
# PUSHBULLET_TOKEN="token-value"

View file

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