5 #GOTIFY_URL="https://gotify.example.com"
6 #GOTIFY_TOKEN="123456789ABCDEF"
11 # subject content statusCode
15 _statusCode
="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
16 _debug
"_subject" "$_subject"
17 _debug
"_content" "$_content"
18 _debug
"_statusCode" "$_statusCode"
20 GOTIFY_URL
="${GOTIFY_URL:-$(_readaccountconf_mutable GOTIFY_URL)}"
21 if [ -z "$GOTIFY_URL" ]; then
23 _err
"You didn't specify the gotify server url GOTIFY_URL."
26 _saveaccountconf_mutable GOTIFY_URL
"$GOTIFY_URL"
28 GOTIFY_TOKEN
="${GOTIFY_TOKEN:-$(_readaccountconf_mutable GOTIFY_TOKEN)}"
29 if [ -z "$GOTIFY_TOKEN" ]; then
31 _err
"You didn't specify the gotify token GOTIFY_TOKEN."
34 _saveaccountconf_mutable GOTIFY_TOKEN
"$GOTIFY_TOKEN"
36 GOTIFY_PRIORITY
="${GOTIFY_PRIORITY:-$(_readaccountconf_mutable GOTIFY_PRIORITY)}"
37 if [ -z "$GOTIFY_PRIORITY" ]; then
40 _saveaccountconf_mutable GOTIFY_PRIORITY
"$GOTIFY_PRIORITY"
43 export _H1
="X-Gotify-Key: ${GOTIFY_TOKEN}"
44 export _H2
="Content-Type: application/json"
46 _content
=$
(echo "$_content" | _json_encode
)
47 _subject
=$
(echo "$_subject" | _json_encode
)
49 _data
="{\"title\": \"${_subject}\", \"message\": \"${_content}\", \"priority\": ${GOTIFY_PRIORITY}}"
51 response
="$(_post "${_data}" "${GOTIFY_URL}/message
" "" "POST
" "application
/json
")"
53 if [ "$?" != "0" ]; then
54 _err
"Failed to send message"
59 _debug2 response
"$response"