mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-04-29 19:32:45 +00:00
Merge 66821466cbb1a77fff7c703865e7c7ab81f8d65b into 40b6db6a2715628aa977ed1853fe5256704010ae
This commit is contained in:
commit
053dd6c38e
38
notify/http.sh
Normal file
38
notify/http.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
#Support http webhooks api
|
||||
|
||||
#HTTP_WEBHOOK="xxxx"
|
||||
|
||||
# subject content statusCode
|
||||
http_send() {
|
||||
_subject="$1"
|
||||
_content="$2"
|
||||
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
|
||||
_debug "_subject" "$_subject"
|
||||
_debug "_content" "$_content"
|
||||
_debug "_statusCode" "$_statusCode"
|
||||
|
||||
HTTP_WEBHOOK="${HTTP_WEBHOOK:-$(_readaccountconf_mutable HTTP_WEBHOOK)}"
|
||||
if [ -z "$HTTP_WEBHOOK" ]; then
|
||||
HTTP_WEBHOOK=""
|
||||
_err "You didn't specify a http webhook HTTP_WEBHOOK yet."
|
||||
return 1
|
||||
fi
|
||||
_saveaccountconf_mutable HTTP_WEBHOOK "$HTTP_WEBHOOK"
|
||||
|
||||
_content=$(echo "$_content" | _json_encode)
|
||||
_subject=$(echo "$_subject" | _json_encode)
|
||||
_data="{\"subject\": \"$_subject\", \"content\": \"$_content\", \"status\": $_statusCode}"
|
||||
|
||||
response="$(_post "$_data" "$HTTP_WEBHOOK" "" "POST" "application/json")"
|
||||
|
||||
if [ "$?" = "0" ]; then
|
||||
_info "http webhooks event fired success."
|
||||
return 0
|
||||
fi
|
||||
|
||||
_err "http webhooks event fired error."
|
||||
_err "$response"
|
||||
return 1
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user