From d13ba926f3f4fbffa363a18003bc466d9a53226a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Nussbaumer?= Date: Sat, 6 Nov 2021 10:41:41 +0100 Subject: [PATCH] fix: make slack integration optional when uri not specified --- cloudflare-template.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cloudflare-template.sh b/cloudflare-template.sh index 6147b7b..60e6776 100644 --- a/cloudflare-template.sh +++ b/cloudflare-template.sh @@ -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