dns_acmedns.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env sh
  2. #
  3. #Author: Wolfgang Ebner
  4. #Report Bugs here: https://github.com/webner/acme.sh
  5. #
  6. ######## Public functions #####################
  7. #Usage: dns_acmedns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  8. dns_acmedns_add() {
  9. fulldomain=$1
  10. txtvalue=$2
  11. _info "Using acme-dns"
  12. _debug fulldomain "$fulldomain"
  13. _debug txtvalue "$txtvalue"
  14. ACMEDNS_UPDATE_URL="${ACMEDNS_UPDATE_URL:-$(_readaccountconf_mutable ACMEDNS_UPDATE_URL)}"
  15. ACMEDNS_USERNAME="${ACMEDNS_USERNAME:-$(_readaccountconf_mutable ACMEDNS_USERNAME)}"
  16. ACMEDNS_PASSWORD="${ACMEDNS_PASSWORD:-$(_readaccountconf_mutable ACMEDNS_PASSWORD)}"
  17. ACMEDNS_SUBDOMAIN="${ACMEDNS_SUBDOMAIN:-$(_readaccountconf_mutable ACMEDNS_SUBDOMAIN)}"
  18. if [ "$ACMEDNS_UPDATE_URL" = "" ]; then
  19. ACMEDNS_UPDATE_URL="https://auth.acme-dns.io/update"
  20. fi
  21. _saveaccountconf_mutable ACMEDNS_UPDATE_URL "$ACMEDNS_UPDATE_URL"
  22. _saveaccountconf_mutable ACMEDNS_USERNAME "$ACMEDNS_USERNAME"
  23. _saveaccountconf_mutable ACMEDNS_PASSWORD "$ACMEDNS_PASSWORD"
  24. _saveaccountconf_mutable ACMEDNS_SUBDOMAIN "$ACMEDNS_SUBDOMAIN"
  25. export _H1="X-Api-User: $ACMEDNS_USERNAME"
  26. export _H2="X-Api-Key: $ACMEDNS_PASSWORD"
  27. data="{\"subdomain\":\"$ACMEDNS_SUBDOMAIN\", \"txt\": \"$txtvalue\"}"
  28. _debug data "$data"
  29. response="$(_post "$data" "$ACMEDNS_UPDATE_URL" "" "POST")"
  30. _debug response "$response"
  31. if ! echo "$response" | grep "\"$txtvalue\"" >/dev/null; then
  32. _err "invalid response of acme-dns"
  33. return 1
  34. fi
  35. }
  36. #Usage: fulldomain txtvalue
  37. #Remove the txt record after validation.
  38. dns_acmedns_rm() {
  39. fulldomain=$1
  40. txtvalue=$2
  41. _info "Using acme-dns"
  42. _debug fulldomain "$fulldomain"
  43. _debug txtvalue "$txtvalue"
  44. }
  45. #################### Private functions below ##################################