Merge pull request #24 from northportio/main

Added Slack Integration
This commit is contained in:
Jason K 2021-11-05 21:27:03 +08:00 committed by GitHub
commit fba6204554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,9 @@ zone_identifier="" # Can be found in the "Overvi
record_name="" # Which record you want to be synced record_name="" # Which record you want to be synced
ttl="3600" # Set the DNS TTL (seconds) ttl="3600" # Set the DNS TTL (seconds)
proxy=false # Set the proxy to true or false proxy=false # Set the proxy to true or false
slacksitename="" # Title of site "Example Site"
slackchannel="" # Slack Channel #example
slackuri="" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx"
@ -78,8 +81,18 @@ update=$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$zone_iden
case "$update" in case "$update" in
*"\"success\":false"*) *"\"success\":false"*)
logger -s "DDNS Updater: $ip $record_name DDNS failed for $record_identifier ($ip). DUMPING RESULTS:\n$update" logger -s "DDNS Updater: $ip $record_name DDNS failed for $record_identifier ($ip). DUMPING RESULTS:\n$update"
curl -L -X POST $slackuri \
--data-raw '{
"channel": "'$slackchannel'",
"text" : "'"$slacksitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
}'
exit 1;; exit 1;;
*) *)
logger "DDNS Updater: $ip $record_name DDNS updated." logger "DDNS Updater: $ip $record_name DDNS updated."
curl -L -X POST $slackuri \
--data-raw '{
"channel": "'$slackchannel'",
"text" : "'"$slacksitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
}'
exit 0;; exit 0;;
esac esac