3 ########################################################################
4 # https://namemaster.de hook script for acme.sh
6 # Environment variables:
8 # - $NM_user (your namemaster.de API username)
9 # - $NM_sha256 (your namemaster.de API password_as_sha256hash)
11 # Author: Thilo Gass <thilo.gass@gmail.com>
12 # Git repo: https://github.com/ThiloGa/acme.sh
14 #-- dns_nm_add() - Add TXT record --------------------------------------
15 # Usage: dns_nm_add _acme-challenge.subdomain.domain.com "XyZ123..."
17 namemaster_api
="https://namemaster.de/api/api.php"
23 _info
"Using DNS-01 namemaster hook"
25 NM_user
="${NM_user:-$(_readaccountconf_mutable NM_user)}"
26 NM_sha256
="${NM_sha256:-$(_readaccountconf_mutable NM_sha256)}"
27 if [ -z "$NM_user" ] ||
[ -z "$NM_sha256" ]; then
30 _err
"No auth details provided. Please set user credentials using the \$NM_user and \$NM_sha256 environment variables."
33 #save the api user and sha256 password to the account conf file.
34 _debug
"Save user and hash"
35 _saveaccountconf_mutable NM_user
"$NM_user"
36 _saveaccountconf_mutable NM_sha256
"$NM_sha256"
39 _debug
"First detect the root zone"
40 if ! _get_root
"$fulldomain"; then
41 _err
"invalid domain" "$fulldomain"
45 _info
"die Zone lautet:" "$zone"
47 get
="$namemaster_api?User=$NM_user&Password=$NM_sha256&Antwort=csv&Typ=ACME&zone=$zone&hostname=$fulldomain&TXT=$txt_value&Action=Auto&Lifetime=3600"
49 if ! erg
="$(_get "$get")"
51 _err
"error Adding $fulldomain TXT: $txt_value"
55 if _contains
"$erg" "Success"; then
56 _info
"Success, TXT Added, OK"
58 _err
"error Adding $fulldomain TXT: $txt_value erg: $erg"
62 _debug
"ok Auto $fulldomain TXT: $txt_value erg: $erg"
71 NM_user
="${NM_user:-$(_readaccountconf_mutable NM_user)}"
72 NM_sha256
="${NM_sha256:-$(_readaccountconf_mutable NM_sha256)}"
73 if [ -z "$NM_user" ] ||
[ -z "$NM_sha256" ]; then
76 _err
"No auth details provided. Please set user credentials using the \$NM_user and \$NM_sha256 environment variables."
81 zone
="$(echo "$fulldomain" | _egrep_o "[^.
]+.
[^.
]+$
")"
82 get
="$namemaster_api?User=$NM_user&Password=$NM_sha256&Antwort=csv&Typ=TXT&Zone=$zone&hostname=$fulldomain&TXT=$txt_value&Action=Delete_IN"
84 if ! erg
="$(_get "$get")"
86 _err
"error Deleting $fulldomain TXT: $txt_value"
90 if _contains
"$erg" "Success"; then
91 _info
"Success, TXT removed, OK"
93 _err
"error Auto $fulldomain TXT: $txt_value erg: $erg"
97 _debug
"ok Auto $fulldomain TXT: $txt_value erg: $erg"
107 get
="$namemaster_api?User=$NM_user&Password=$NM_sha256&Typ=acme&hostname=$domain&Action=getzone&antwort=csv"
109 if ! zone
="$(_get "$get")"
111 _err
"error getting Zone"
114 if _contains
"$zone" "hostname not found"