Merge pull request #25 from clementnuss/optional-slack

fix: make slack integration optional when uri not specified
This commit is contained in:
Jason K 2021-11-06 17:59:28 +08:00 committed by GitHub
commit f556d0e5dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 10 deletions

View File

@ -81,18 +81,22 @@ update=$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$zone_iden
case "$update" in
*"\"success\":false"*)
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')."
}'
if [[ $slackuri != "" ]]; then
curl -L -X POST $slackuri \
--data-raw '{
"channel": "'$slackchannel'",
"text" : "'"$slacksitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
}'
fi
exit 1;;
*)
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'"
}'
if [[ $slackuri != "" ]]; then
curl -L -X POST $slackuri \
--data-raw '{
"channel": "'$slackchannel'",
"text" : "'"$slacksitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
}'
fi
exit 0;;
esac