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.

59 lines
1.7 KiB

  1. #!/usr/bin/env sh
  2. # Official Let's Encrypt API for do.de / Domain-Offensive
  3. #
  4. # This is different from the dns_do adapter, because dns_do is only usable for enterprise customers
  5. # This API is also available to private customers/individuals
  6. #
  7. # Provide the required LetsEncrypt token like this:
  8. # DO_LETOKEN="FmD408PdqT1E269gUK57"
  9. DO_API="https://www.do.de/api/letsencrypt"
  10. ######## Public functions #####################
  11. #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  12. dns_doapi_add() {
  13. fulldomain=$1
  14. txtvalue=$2
  15. DO_LETOKEN="${DO_LETOKEN:-$(_readaccountconf_mutable DO_LETOKEN)}"
  16. if [ -z "$DO_LETOKEN" ]; then
  17. DO_LETOKEN=""
  18. _err "You didn't configure a do.de API token yet."
  19. _err "Please set DO_LETOKEN and try again."
  20. return 1
  21. fi
  22. _saveaccountconf_mutable DO_LETOKEN "$DO_LETOKEN"
  23. _info "Adding TXT record to ${fulldomain}"
  24. response="$(_get "$DO_API?token=$DO_LETOKEN&domain=${fulldomain}&value=${txtvalue}")"
  25. if _contains "${response}" 'success'; then
  26. return 0
  27. fi
  28. _err "Could not create resource record, check logs"
  29. _err "${response}"
  30. return 1
  31. }
  32. dns_doapi_rm() {
  33. fulldomain=$1
  34. DO_LETOKEN="${DO_LETOKEN:-$(_readaccountconf_mutable DO_LETOKEN)}"
  35. if [ -z "$DO_LETOKEN" ]; then
  36. DO_LETOKEN=""
  37. _err "You didn't configure a do.de API token yet."
  38. _err "Please set DO_LETOKEN and try again."
  39. return 1
  40. fi
  41. _saveaccountconf_mutable DO_LETOKEN "$DO_LETOKEN"
  42. _info "Deleting resource record $fulldomain"
  43. response="$(_get "$DO_API?token=$DO_LETOKEN&domain=${fulldomain}&action=delete")"
  44. if _contains "${response}" 'success'; then
  45. return 0
  46. fi
  47. _err "Could not delete resource record, check logs"
  48. _err "${response}"
  49. return 1
  50. }