Skip to content

Commit

Permalink
Merge pull request #3734 from acmesh-official/dev
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
Neilpang authored Oct 3, 2021
2 parents ae25931 + f5ee618 commit 8fcecd5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dnsapi/dns_he.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ dns_he_rm() {
_debug "The txt record is not found, just skip"
return 0
fi
_record_id="$(echo "$response" | tr -d "#" | sed "s/<tr/#<tr/g" | tr -d "\n" | tr "#" "\n" | grep "$_full_domain" | grep '"dns_tr"' | grep "$_txt_value" | cut -d '"' -f 4)"
_record_id="$(echo "$response" | tr -d "#" | sed "s/<tr/#<tr/g" | tr -d "\n" | tr "#" "\n" | grep "$_full_domain" | grep '"dns_tr"' | grep -- "$_txt_value" | cut -d '"' -f 4)"
_debug2 _record_id "$_record_id"
if [ -z "$_record_id" ]; then
_err "Can not find record id"
Expand Down
44 changes: 44 additions & 0 deletions notify/pushbullet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env sh

#Support for pushbullet.com's api. Push notification, notification sync and message platform for multiple platforms
#PUSHBULLET_TOKEN="" Required, pushbullet application token
#PUSHBULLET_DEVICE="" Optional, Specific device, ignore to send to all devices

PUSHBULLET_URI="https://api.pushbullet.com/v2/pushes"
pushbullet_send() {
_subject="$1"
_content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_statusCode" "$_statusCode"

PUSHBULLET_TOKEN="${PUSHBULLET_TOKEN:-$(_readaccountconf_mutable PUSHBULLET_TOKEN)}"
if [ -z "$PUSHBULLET_TOKEN" ]; then
PUSHBULLET_TOKEN=""
_err "You didn't specify a Pushbullet application token yet."
return 1
fi
_saveaccountconf_mutable PUSHBULLET_TOKEN "$PUSHBULLET_TOKEN"

PUSHBULLET_DEVICE="${PUSHBULLET_DEVICE:-$(_readaccountconf_mutable PUSHBULLET_DEVICE)}"
if [ -z "$PUSHBULLET_DEVICE" ]; then
_clearaccountconf_mutable PUSHBULLET_DEVICE
else
_saveaccountconf_mutable PUSHBULLET_DEVICE "$PUSHBULLET_DEVICE"
fi

export _H1="Content-Type: application/json"
export _H2="Access-Token: ${PUSHBULLET_TOKEN}"
_content="$(printf "*%s*\n" "$_content" | _json_encode)"
_subject="$(printf "*%s*\n" "$_subject" | _json_encode)"
_data="{\"type\": \"note\",\"title\": \"${_subject}\",\"body\": \"${_content}\",\"device_iden\": \"${PUSHBULLET_DEVICE}\"}"
response="$(_post "$_data" "$PUSHBULLET_URI")"

if [ "$?" != "0" ] || _contains "$response" "\"error_code\""; then
_err "PUSHBULLET send error."
_err "$response"
return 1
fi

_info "PUSHBULLET send success."
return 0
}

0 comments on commit 8fcecd5

Please sign in to comment.