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.

90 lines
2.6 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_md5 (your namemaster.de API password_as_md5hash)
  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. 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_md5="${NM_md5:-$(_readaccountconf_mutable NM_md5)}"
  20. if [ -z "$NM_user" ] || [ -z "$NM_md5" ]; then
  21. NM_user=""
  22. NM_md5=""
  23. _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_md5 environment variables."
  24. return 1
  25. fi
  26. #save the api user and md5 password to the account conf file.
  27. _debug "Save user and hash"
  28. _saveaccountconf_mutable NM_user "$NM_user"
  29. _saveaccountconf_mutable NM_md5 "$NM_md5"
  30. zone="$(echo $fulldomain | _egrep_o "[^.]+.[^.]+$")"
  31. get="https://namemaster.de/api/api.php?User=$NM_user&Password=$NM_md5&Antwort=csv&Int=0&Typ=ACME&Zone=$zone&hostname=$fulldomain&TXT=$txt_value&Action=Auto&Lifetime=3600"
  32. erg="$(_get "$get")"
  33. if [ "$?" != "0" ]; then
  34. _err "error Auto $zone TXT: $txt"
  35. _err "Error $?"
  36. return 1
  37. fi
  38. if _contains "$erg" "Success"; then
  39. _info "Success, TXT Added, OK"
  40. else
  41. _err "error Auto $zone TXT: $txt erg: $erg"
  42. return 1
  43. fi
  44. _debug "ok Auto $zone TXT: $txt erg: $erg"
  45. return 0
  46. }
  47. dns_nm_rm() {
  48. fulldomain=$1
  49. txt_value=$2
  50. NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
  51. NM_md5="${NM_md5:-$(_readaccountconf_mutable NM_md5)}"
  52. if [ -z "$NM_user" ] || [ -z "$NM_md5" ]; then
  53. NM_user=""
  54. NM_md5=""
  55. _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_md5 environment variables."
  56. return 1
  57. fi
  58. zone="$(echo $fulldomain | _egrep_o "[^.]+.[^.]+$")"
  59. get="https://namemaster.de/api/api.php?User=$NM_user&Password=$NM_md5&Antwort=csv&Int=0&Typ=TXT&Zone=$zone&hostname=$fulldomain&TXT=$txt_value&Action=Delete_IN&TTL=0"
  60. erg="$(_get "$get")"
  61. if [ "$?" != "0" ]; then
  62. _err "error $action $zone TXT: $txt"
  63. _err "Error $?"
  64. return 1
  65. fi
  66. if _contains "$erg" "Success"; then
  67. _info "Success, TXT removed, OK"
  68. else
  69. _err "error Auto $zone TXT: $txt erg: $erg"
  70. return 1
  71. fi
  72. _debug "ok Auto $zone TXT: $txt erg: $erg"
  73. return 0
  74. }