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.

62 lines
1.9 KiB

2 years ago
2 years ago
2 years ago
  1. #!/usr/bin/env sh
  2. # shellcheck disable=SC2034
  3. dns_nanelo_info='Nanelo.com
  4. Site: Nanelo.com
  5. Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_nanelo
  6. Options:
  7. NANELO_TOKEN API Token
  8. Issues: github.com/acmesh-official/acme.sh/issues/4519
  9. '
  10. NANELO_API="https://api.nanelo.com/v1/"
  11. ######## Public functions #####################
  12. # Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  13. dns_nanelo_add() {
  14. fulldomain=$1
  15. txtvalue=$2
  16. NANELO_TOKEN="${NANELO_TOKEN:-$(_readaccountconf_mutable NANELO_TOKEN)}"
  17. if [ -z "$NANELO_TOKEN" ]; then
  18. NANELO_TOKEN=""
  19. _err "You didn't configure a Nanelo API Key yet."
  20. _err "Please set NANELO_TOKEN and try again."
  21. _err "Login to Nanelo.com and go to Settings > API Keys to get a Key"
  22. return 1
  23. fi
  24. _saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
  25. _info "Adding TXT record to ${fulldomain}"
  26. response="$(_get "$NANELO_API$NANELO_TOKEN/dns/addrecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
  27. if _contains "${response}" 'success'; then
  28. return 0
  29. fi
  30. _err "Could not create resource record, please check the logs"
  31. _err "${response}"
  32. return 1
  33. }
  34. dns_nanelo_rm() {
  35. fulldomain=$1
  36. txtvalue=$2
  37. NANELO_TOKEN="${NANELO_TOKEN:-$(_readaccountconf_mutable NANELO_TOKEN)}"
  38. if [ -z "$NANELO_TOKEN" ]; then
  39. NANELO_TOKEN=""
  40. _err "You didn't configure a Nanelo API Key yet."
  41. _err "Please set NANELO_TOKEN and try again."
  42. _err "Login to Nanelo.com and go to Settings > API Keys to get a Key"
  43. return 1
  44. fi
  45. _saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
  46. _info "Deleting resource record $fulldomain"
  47. response="$(_get "$NANELO_API$NANELO_TOKEN/dns/deleterecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
  48. if _contains "${response}" 'success'; then
  49. return 0
  50. fi
  51. _err "Could not delete resource record, please check the logs"
  52. _err "${response}"
  53. return 1
  54. }