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.

92 lines
2.7 KiB

5 years ago
  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. exit_code="$?"
  34. if [ "$exit_code" != 0 ]; then
  35. _err "error Ading $zone TXT: $txt_value"
  36. _err "Error $exit_code"
  37. return 1
  38. fi
  39. if _contains "$erg" "Success"; then
  40. _info "Success, TXT Added, OK"
  41. else
  42. _err "error Adding $zone TXT: $txt_value erg: $erg"
  43. return 1
  44. fi
  45. _debug "ok Auto $zone TXT: $txt_value erg: $erg"
  46. return 0
  47. }
  48. dns_nm_rm() {
  49. fulldomain=$1
  50. txt_value=$2
  51. NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
  52. NM_md5="${NM_md5:-$(_readaccountconf_mutable NM_md5)}"
  53. if [ -z "$NM_user" ] || [ -z "$NM_md5" ]; then
  54. NM_user=""
  55. NM_md5=""
  56. _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_md5 environment variables."
  57. return 1
  58. fi
  59. zone="$(echo $fulldomain | _egrep_o "[^.]+.[^.]+$")"
  60. 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"
  61. erg="$(_get "$get")"
  62. exit_code="$?"
  63. if [ "$exit_code" != "0" ]; then
  64. _err "error Deleting $zone TXT: $txt_value"
  65. _err "Error $exit_code"
  66. return 1
  67. fi
  68. if _contains "$erg" "Success"; then
  69. _info "Success, TXT removed, OK"
  70. else
  71. _err "error Auto $zone TXT: $txt_value erg: $erg"
  72. return 1
  73. fi
  74. _debug "ok Auto $zone TXT: $txt_value erg: $erg"
  75. return 0
  76. }