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.

86 lines
2.2 KiB

  1. #!/usr/bin/env sh
  2. # shellcheck disable=SC2034
  3. dns_nm_info='NameMaster.de
  4. Site: NameMaster.de
  5. Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_nm
  6. Options:
  7. NM_user API Username
  8. NM_sha256 API Password as SHA256 hash
  9. Author: Thilo Gass <thilo.gass@gmail.com>
  10. '
  11. #-- dns_nm_add() - Add TXT record --------------------------------------
  12. # Usage: dns_nm_add _acme-challenge.subdomain.domain.com "XyZ123..."
  13. namemaster_api="https://namemaster.de/api/api.php"
  14. dns_nm_add() {
  15. fulldomain=$1
  16. txt_value=$2
  17. _info "Using DNS-01 namemaster hook"
  18. NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
  19. NM_sha256="${NM_sha256:-$(_readaccountconf_mutable NM_sha256)}"
  20. if [ -z "$NM_user" ] || [ -z "$NM_sha256" ]; then
  21. NM_user=""
  22. NM_sha256=""
  23. _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_sha256 environment variables."
  24. return 1
  25. fi
  26. #save the api user and sha256 password to the account conf file.
  27. _debug "Save user and hash"
  28. _saveaccountconf_mutable NM_user "$NM_user"
  29. _saveaccountconf_mutable NM_sha256 "$NM_sha256"
  30. _debug "First detect the root zone"
  31. if ! _get_root "$fulldomain"; then
  32. _err "invalid domain" "$fulldomain"
  33. return 1
  34. fi
  35. _info "die Zone lautet:" "$zone"
  36. get="$namemaster_api?User=$NM_user&Password=$NM_sha256&Antwort=csv&Typ=ACME&zone=$zone&hostname=$fulldomain&TXT=$txt_value&Action=Auto&Lifetime=3600"
  37. if ! erg="$(_get "$get")"; then
  38. _err "error Adding $fulldomain TXT: $txt_value"
  39. return 1
  40. fi
  41. if _contains "$erg" "Success"; then
  42. _info "Success, TXT Added, OK"
  43. else
  44. _err "error Adding $fulldomain TXT: $txt_value erg: $erg"
  45. return 1
  46. fi
  47. _debug "ok Auto $fulldomain TXT: $txt_value erg: $erg"
  48. return 0
  49. }
  50. dns_nm_rm() {
  51. fulldomain=$1
  52. txtvalue=$2
  53. _info "TXT enrty in $fulldomain is deleted automatically"
  54. _debug fulldomain "$fulldomain"
  55. _debug txtvalue "$txtvalue"
  56. }
  57. _get_root() {
  58. domain=$1
  59. get="$namemaster_api?User=$NM_user&Password=$NM_sha256&Typ=acme&hostname=$domain&Action=getzone&antwort=csv"
  60. if ! zone="$(_get "$get")"; then
  61. _err "error getting Zone"
  62. return 1
  63. else
  64. if _contains "$zone" "hostname not found"; then
  65. return 1
  66. fi
  67. fi
  68. }