From 47e3d06311e79470eab4e15d5c514465d5297e77 Mon Sep 17 00:00:00 2001 From: Avi0n <14863961+Avi0n@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:41:26 -0700 Subject: [PATCH] Add ntfy notification provider Add ntfy notification provider, including support for custom ntfy servers. --- cloudflare-template.sh | 16 ++++++++++++++++ cloudflare-templatev6.sh | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/cloudflare-template.sh b/cloudflare-template.sh index 0834eaa..122b498 100644 --- a/cloudflare-template.sh +++ b/cloudflare-template.sh @@ -12,6 +12,8 @@ sitename="" # Title of site "Example Sit slackchannel="" # Slack Channel #example slackuri="" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx" discorduri="" # URI for Discord WebHook "https://discordapp.com/api/webhooks/xxxxx" +ntfyuri="ntfy.sh" # URI for ntfy server. Default is ntfy.sh +ntfytopic="" # Topic for ntfy.sh "https://ntfy.sh/xxxxx" ########################################### @@ -103,6 +105,14 @@ case "$update" in "content" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')." }' $discorduri fi + if [[ $ntfytopic != "" ]]; then + curl \ + -H "Title: $sitename DDNS Update Failed" \ + -H "Priority: urgent" \ + -H "Tags: warning" \ + -d "'$record_name': '$record_identifier' ('$ip')." \ + $ntfyuri/$ntfytopic + fi exit 1;; *) logger "DDNS Updater: $ip $record_name DDNS updated." @@ -119,5 +129,11 @@ case "$update" in "content" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'" }' $discorduri fi + if [[ $ntfytopic != "" ]]; then + curl \ + -H "Title: $sitename Updated" \ + -d $record_name"'s new IP Address is '$ip'" \ + $ntfyuri/$ntfytopic + fi exit 0;; esac diff --git a/cloudflare-templatev6.sh b/cloudflare-templatev6.sh index 54b91f8..f3a7f3d 100644 --- a/cloudflare-templatev6.sh +++ b/cloudflare-templatev6.sh @@ -39,11 +39,15 @@ log_header_name="DDNS Updater_v6" # @slackchannel - Slack Channel #example # @slackuri - URI for Slack WebHook "https://hooks.slack.com/services/xxxxx" # @discorduri - URI for Discord WebHook "https://discordapp.com/api/webhooks/xxxxx" +# @ntfyuri - URI for ntfy server. Default is ntfy.sh +# @ntfytopic - Topic for Ntfy.sh "https://ntfy.sh/xxxxx" # -------------------------------------------------- # sitename="" slackchannel="" slackuri="" discorduri="" +ntfyuri="ntfy.sh" +ntfytopic="" @@ -164,6 +168,14 @@ case "$update" in \"content\": \"$sitename DDNS Update Failed: $record_name: $record_identifier ($ip).\" }" $discorduri fi + if [[ $ntfytopic != "" ]]; then + curl \ + -H "Title: $sitename DDNS Update Failed" \ + -H "Priority: urgent" \ + -H "Tags: warning" \ + -d "$record_name: $record_identifier ($ip)." \ + $ntfyuri/$ntfytopic + fi exit 1 ;; *) @@ -181,6 +193,12 @@ case "$update" in \"content\": \"$sitename Updated: $record_name's new IPv6 Address is $ip\" }" $discorduri fi + if [[ $ntfytopic != "" ]]; then + curl \ + -H "Title: $sitename Updated" \ + -d $record_name"'s new IP Address is $ip" \ + $ntfyuri/$ntfytopic + fi exit 0 ;; esac