Browse Source

sync

pull/2691/head
neilpang 5 years ago
parent
commit
2cbc04e04d
  1. 14
      acme.sh
  2. 8
      dnsapi/dns_desec.sh
  3. 2
      dnsapi/dns_dp.sh
  4. 86
      notify/ifttt.sh
  5. 8
      notify/pushover.sh
  6. 8
      notify/sendgrid.sh

14
acme.sh

@ -3623,7 +3623,7 @@ _ns_purge_cf() {
_cf_d="$1"
_cf_d_type="$2"
_debug "Cloudflare purge $_cf_d_type record for domain $_cf_d"
_cf_purl="https://1.0.0.1/api/v1/purge?domain=$_cf_d&type=$_cf_d_type"
_cf_purl="https://cloudflare-dns.com/api/v1/purge?domain=$_cf_d&type=$_cf_d_type"
response="$(_post "" "$_cf_purl")"
_debug2 response "$response"
}
@ -3682,11 +3682,11 @@ _check_dns_entries() {
fi
_left=1
_info "Not valid yet, let's wait 10 seconds and check next one."
_sleep 10
__purge_txt "$txtdomain"
if [ "$txtdomain" != "$aliasDomain" ]; then
__purge_txt "$aliasDomain"
fi
_sleep 10
done
if [ "$_left" ]; then
_info "Let's wait 10 seconds and check again".
@ -5932,8 +5932,12 @@ _send_notify() {
_send_err=0
for _n_hook in $(echo "$_nhooks" | tr ',' " "); do
_n_hook_file="$(_findHook "" $_SUB_FOLDER_NOTIFY "$_n_hook")"
_info "Found $_n_hook_file"
_info "Sending via: $_n_hook"
_debug "Found $_n_hook_file for $_n_hook"
if [ -z "$_n_hook_file" ]; then
_err "Can not find the hook file for $_n_hook"
continue
fi
if ! (
if ! . "$_n_hook_file"; then
_err "Load file $_n_hook_file error. Please check your api file and try again."
@ -5968,7 +5972,7 @@ _set_notify_hook() {
_nhooks="$1"
_test_subject="Hello, this is notification from $PROJECT_NAME"
_test_content="If you receive this email, your notification works."
_test_content="If you receive this message, your notification works."
_send_notify "$_test_subject" "$_test_content" "$_nhooks" 0

8
dnsapi/dns_desec.sh

@ -25,8 +25,8 @@ dns_desec_add() {
if [ -z "$DEDYN_TOKEN" ] || [ -z "$DEDYN_NAME" ]; then
DEDYN_TOKEN=""
DEDYN_NAME=""
_err "You don't specify DEDYN_TOKEN and DEDYN_NAME yet."
_err "Please create you key and try again."
_err "You did not specify DEDYN_TOKEN and DEDYN_NAME yet."
_err "Please create your key and try again."
_err "e.g."
_err "export DEDYN_TOKEN=d41d8cd98f00b204e9800998ecf8427e"
_err "export DEDYN_NAME=foobar.dedyn.io"
@ -92,8 +92,8 @@ dns_desec_rm() {
if [ -z "$DEDYN_TOKEN" ] || [ -z "$DEDYN_NAME" ]; then
DEDYN_TOKEN=""
DEDYN_NAME=""
_err "You don't specify DEDYN_TOKEN and DEDYN_NAME yet."
_err "Please create you key and try again."
_err "You did not specify DEDYN_TOKEN and DEDYN_NAME yet."
_err "Please create your key and try again."
_err "e.g."
_err "export DEDYN_TOKEN=d41d8cd98f00b204e9800998ecf8427e"
_err "export DEDYN_NAME=foobar.dedyn.io"

2
dnsapi/dns_dp.sh

@ -63,7 +63,7 @@ dns_dp_rm() {
return 0
fi
record_id=$(echo "$response" | tr "{" "\n" | grep "$txtvalue" | grep '^"id"' | cut -d : -f 2 | cut -d '"' -f 2)
record_id=$(echo "$response" | tr "{" "\n" | grep -- "$txtvalue" | grep '^"id"' | cut -d : -f 2 | cut -d '"' -f 2)
_debug record_id "$record_id"
if [ -z "$record_id" ]; then
_err "Can not get record id."

86
notify/ifttt.sh

@ -0,0 +1,86 @@
#!/usr/bin/env sh
#Support ifttt.com webhooks api
#IFTTT_API_KEY="xxxx"
#IFTTT_EVENT_NAME="yyyy"
#IFTTT_SUBJECT_KEY="value1|value2|value3" #optional, use "value1" as default
#IFTTT_CONTENT_KEY="value1|value2|value3" #optional, use "value2" as default
_IFTTT_AVAIL_MSG_KEYS="value1,value2,value3"
# subject content statusCode
ifttt_send() {
_subject="$1"
_content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_subject" "$_subject"
_debug "_content" "$_content"
_debug "_statusCode" "$_statusCode"
IFTTT_API_KEY="${IFTTT_API_KEY:-$(_readaccountconf_mutable IFTTT_API_KEY)}"
if [ -z "$IFTTT_API_KEY" ]; then
IFTTT_API_KEY=""
_err "You didn't specify a ifttt webhooks api key IFTTT_API_KEY yet."
_err "You can get yours from https://ifttt.com"
return 1
fi
_saveaccountconf_mutable IFTTT_API_KEY "$IFTTT_API_KEY"
IFTTT_EVENT_NAME="${IFTTT_EVENT_NAME:-$(_readaccountconf_mutable IFTTT_EVENT_NAME)}"
if [ -z "$IFTTT_EVENT_NAME" ]; then
IFTTT_EVENT_NAME=""
_err "You didn't specify a ifttt webhooks event name IFTTT_EVENT_NAME yet."
return 1
fi
_saveaccountconf_mutable IFTTT_EVENT_NAME "$IFTTT_EVENT_NAME"
IFTTT_SUBJECT_KEY="${IFTTT_SUBJECT_KEY:-$(_readaccountconf_mutable IFTTT_SUBJECT_KEY)}"
if [ -z "$IFTTT_SUBJECT_KEY" ]; then
IFTTT_SUBJECT_KEY="value1"
_info "The IFTTT_SUBJECT_KEY is not set, so use the default value1 as key."
elif ! _hasfield "$_IFTTT_AVAIL_MSG_KEYS" "$IFTTT_SUBJECT_KEY"; then
_err "The IFTTT_SUBJECT_KEY \"$IFTTT_SUBJECT_KEY\" is not available, should be one of $_IFTTT_AVAIL_MSG_KEYS"
IFTTT_SUBJECT_KEY=""
return 1
else
_saveaccountconf_mutable IFTTT_SUBJECT_KEY "$IFTTT_SUBJECT_KEY"
fi
IFTTT_CONTENT_KEY="${IFTTT_CONTENT_KEY:-$(_readaccountconf_mutable IFTTT_CONTENT_KEY)}"
if [ -z "$IFTTT_CONTENT_KEY" ]; then
IFTTT_CONTENT_KEY="value2"
_info "The IFTTT_CONTENT_KEY is not set, so use the default value2 as key."
elif ! _hasfield "$_IFTTT_AVAIL_MSG_KEYS" "$IFTTT_CONTENT_KEY"; then
_err "The IFTTT_CONTENT_KEY \"$IFTTT_CONTENT_KEY\" is not available, should be one of $_IFTTT_AVAIL_MSG_KEYS"
IFTTT_CONTENT_KEY=""
return 1
else
_saveaccountconf_mutable IFTTT_CONTENT_KEY "$IFTTT_CONTENT_KEY"
fi
if [ "$IFTTT_SUBJECT_KEY" = "$IFTTT_CONTENT_KEY" ]; then
IFTTT_SUBJECT_KEY=""
IFTTT_CONTENT_KEY=""
_err "The IFTTT_SUBJECT_KEY must not be same as IFTTT_CONTENT_KEY."
return 1
fi
IFTTT_API_URL="https://maker.ifttt.com/trigger/$IFTTT_EVENT_NAME/with/key/$IFTTT_API_KEY"
_content=$(echo "$_content" | _json_encode)
_subject=$(echo "$_subject" | _json_encode)
_data="{\"$IFTTT_SUBJECT_KEY\": \"$_subject\", \"$IFTTT_CONTENT_KEY\": \"$_content\"}"
response="$(_post "$_data" "$IFTTT_API_URL" "" "POST" "application/json")"
if [ "$?" = "0" ] && _contains "$response" "Congratulations"; then
_info "IFTTT webhooks event fired success."
return 0
fi
_err "IFTTT webhooks event fired error."
_err "$response"
return 1
}

8
notify/pushover.sh

@ -50,13 +50,13 @@ pushover_send() {
_subject="$(printf "*%s*\n" "$_subject" | _json_encode)"
_data="{\"token\": \"$PUSHOVER_TOKEN\",\"user\": \"$PUSHOVER_USER\",\"title\": \"$_subject\",\"message\": \"$_content\",\"sound\": \"$PUSHOVER_SOUND\", \"device\": \"$PUSHOVER_DEVICE\", \"priority\": \"$PUSHOVER_PRIORITY\"}"
response="" #just make shellcheck happy
if _post "$_data" "$PUSHOVER_URI"; then
if _contains "$response" "{\"status\":1"; then
response="$(_post "$_data" "$PUSHOVER_URI")"
if [ "$?" = "0" ] && _contains "$response" "{\"status\":1"; then
_info "PUSHOVER send success."
return 0
fi
fi
_err "PUSHOVER send error."
_err "$response"
return 1

8
notify/sendgrid.sh

@ -42,13 +42,13 @@ sendgrid_send() {
_content="$(echo "$_content" | _json_encode)"
_data="{\"personalizations\": [{\"to\": [{\"email\": \"$SENDGRID_TO\"}]}],\"from\": {\"email\": \"$SENDGRID_FROM\"},\"subject\": \"$_subject\",\"content\": [{\"type\": \"text/plain\", \"value\": \"$_content\"}]}"
response="" #just make shellcheck happy
if _post "$_data" "https://api.sendgrid.com/v3/mail/send"; then
if [ -z "$response" ]; then
response="$(_post "$_data" "https://api.sendgrid.com/v3/mail/send")"
if [ "$?" = "0" ] && [ -z "$response" ]; then
_info "sendgrid send sccess."
return 0
fi
fi
_err "sendgrid send error."
_err "$response"
return 1

Loading…
Cancel
Save