feat: replaced slack with nextcloud talk api call

pull/30/head
Richard Holzeis 4 years ago
parent 901fdb403c
commit 4deb9b7de4
  1. 44
      cloudflare-template.sh

@ -1,17 +1,26 @@
#!/bin/bash #!/bin/bash
## change to "bin/sh" when necessary ## change to "bin/sh" when necessary
auth_email="" # The email used to login 'https://dash.cloudflare.com' cf_email=$1
cf_apikey=$2
cf_record=$3
talk_roomuri=$4
talk_username=$5
talk_token=$6
auth_email=$1 # The email used to login 'https://dash.cloudflare.com'
auth_method="token" # Set to "global" for Global API Key or "token" for Scoped API Token auth_method="token" # Set to "global" for Global API Key or "token" for Scoped API Token
auth_key="" # Your API Token or Global API Key auth_key=$2 # Your API Token or Global API Key
zone_identifier="" # Can be found in the "Overview" tab of your domain zone_identifier="" # Can be found in the "Overview" tab of your domain
record_name="" # Which record you want to be synced record_name=$3 # 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" talkroomuri=$talk_roomuri # URI for nextcloud talk webhook "https://nextcloud.holzeis.me/ocs/v2.php/apps/spreed/api/v1/chat/xxxxx"
slackchannel="" # Slack Channel #example talkusername=$talk_username # Webhook user name (needs to be moderator of chat)
slackuri="" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx" talktoken=$talk_token # API Token for user name
########################################### ###########################################
@ -81,21 +90,26 @@ 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"
if [[ $slackuri != "" ]]; then if [[ $talkroomuri != "" ]]; then
curl -L -X POST $slackuri \
curl -L -X POST $talkroomuri \
-H "Content-Type: application/json" \
-H "OCS-APIRequest: true" \
-u "'$talkusername':'$talktoken'"
--data-raw '{ --data-raw '{
"channel": "'$slackchannel'", "message": "DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
"text" : "'"$slacksitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
}' }'
fi fi
exit 1;; exit 1;;
*) *)
logger "DDNS Updater: $ip $record_name DDNS updated." logger "DDNS Updater: $ip $record_name DDNS updated."
if [[ $slackuri != "" ]]; then if [[ $talkroomuri != "" ]]; then
curl -L -X POST $slackuri \ curl -L -X POST $talkroomuri \
-H "Content-Type: application/json" \
-H "OCS-APIRequest: true" \
-u "'$talkusername':'$talktoken'"
--data-raw '{ --data-raw '{
"channel": "'$slackchannel'", "message" : "Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
"text" : "'"$slacksitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
}' }'
fi fi
exit 0;; exit 0;;

Loading…
Cancel
Save