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.

88 lines
2.3 KiB

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