Merge pull request #36 from AgingOrange/main

Add Discord notification. Rename slacksitename to sitename as they wi…
This commit is contained in:
Jason K 2022-04-06 22:07:56 +08:00 committed by GitHub
commit 88c73e30f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 13 deletions

View File

@ -1,17 +1,17 @@
#!/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' auth_email="" # 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="" # 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="" # 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" sitename="" # Title of site "Example Site"
slackchannel="" # Slack Channel #example slackchannel="" # Slack Channel #example
slackuri="" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx" slackuri="" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx"
discorduri="" # URI for Discord WebHook "https://discordapp.com/api/webhooks/xxxxx"
########################################### ###########################################
@ -94,9 +94,15 @@ case "$update" in
curl -L -X POST $slackuri \ curl -L -X POST $slackuri \
--data-raw '{ --data-raw '{
"channel": "'$slackchannel'", "channel": "'$slackchannel'",
"text" : "'"$slacksitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')." "text" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
}' }'
fi fi
if [[ $discorduri != "" ]]; then
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST \
--data-raw '{
"content" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
}' $discorduri
fi
exit 1;; exit 1;;
*) *)
logger "DDNS Updater: $ip $record_name DDNS updated." logger "DDNS Updater: $ip $record_name DDNS updated."
@ -104,8 +110,14 @@ case "$update" in
curl -L -X POST $slackuri \ curl -L -X POST $slackuri \
--data-raw '{ --data-raw '{
"channel": "'$slackchannel'", "channel": "'$slackchannel'",
"text" : "'"$slacksitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'" "text" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
}' }'
fi fi
if [[ $discorduri != "" ]]; then
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST \
--data-raw '{
"content" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
}' $discorduri
fi
exit 0;; exit 0;;
esac esac