You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
895 B

  1. #!/usr/bin/env sh
  2. # support ntfy
  3. #NTFY_URL="https://ntfy.sh"
  4. #NTFY_TOPIC="xxxxxxxxxxxxx"
  5. ntfy_send() {
  6. _subject="$1"
  7. _content="$2"
  8. _statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
  9. _debug "_subject" "$_subject"
  10. _debug "_content" "$_content"
  11. _debug "_statusCode" "$_statusCode"
  12. NTFY_URL="${NTFY_URL:-$(_readaccountconf_mutable NTFY_URL)}"
  13. if [ "$NTFY_URL" ]; then
  14. _saveaccountconf_mutable NTFY_URL "$NTFY_URL"
  15. fi
  16. NTFY_TOPIC="${NTFY_TOPIC:-$(_readaccountconf_mutable NTFY_TOPIC)}"
  17. if [ "$NTFY_TOPIC" ]; then
  18. _saveaccountconf_mutable NTFY_TOPIC "$NTFY_TOPIC"
  19. fi
  20. _data="${_subject}. $_content"
  21. response="$(_post "$_data" "$NTFY_URL/$NTFY_TOPIC" "" "POST" "")"
  22. if [ "$?" = "0" ] && _contains "$response" "expires"; then
  23. _info "ntfy event fired success."
  24. return 0
  25. fi
  26. _err "ntfy event fired error."
  27. _err "$response"
  28. return 1
  29. }