2020-03-07 14:55:09 +01:00
|
|
|
#!/usr/bin/env sh
|
2023-11-18 17:57:12 +01:00
|
|
|
# shellcheck disable=SC2034
|
|
|
|
dns_nm_info='NameMaster.de
|
|
|
|
Site: NameMaster.de
|
|
|
|
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_nm
|
|
|
|
Options:
|
|
|
|
NM_user API Username
|
|
|
|
NM_sha256 API Password as SHA256 hash
|
|
|
|
Author: Thilo Gass <thilo.gass@gmail.com>
|
|
|
|
'
|
2020-03-07 14:55:09 +01:00
|
|
|
|
|
|
|
#-- dns_nm_add() - Add TXT record --------------------------------------
|
|
|
|
# Usage: dns_nm_add _acme-challenge.subdomain.domain.com "XyZ123..."
|
|
|
|
|
2020-03-21 19:28:16 +01:00
|
|
|
namemaster_api="https://namemaster.de/api/api.php"
|
|
|
|
|
2020-03-07 14:55:09 +01:00
|
|
|
dns_nm_add() {
|
|
|
|
fulldomain=$1
|
|
|
|
txt_value=$2
|
|
|
|
_info "Using DNS-01 namemaster hook"
|
2020-03-07 15:18:25 +01:00
|
|
|
|
2020-03-07 14:55:09 +01:00
|
|
|
NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
|
2020-03-21 19:28:16 +01:00
|
|
|
NM_sha256="${NM_sha256:-$(_readaccountconf_mutable NM_sha256)}"
|
|
|
|
if [ -z "$NM_user" ] || [ -z "$NM_sha256" ]; then
|
2020-03-07 14:55:09 +01:00
|
|
|
NM_user=""
|
2020-03-21 19:28:16 +01:00
|
|
|
NM_sha256=""
|
|
|
|
_err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_sha256 environment variables."
|
2020-03-07 14:55:09 +01:00
|
|
|
return 1
|
|
|
|
fi
|
2020-03-21 19:28:16 +01:00
|
|
|
#save the api user and sha256 password to the account conf file.
|
2020-03-07 14:55:09 +01:00
|
|
|
_debug "Save user and hash"
|
|
|
|
_saveaccountconf_mutable NM_user "$NM_user"
|
2020-03-21 19:28:16 +01:00
|
|
|
_saveaccountconf_mutable NM_sha256 "$NM_sha256"
|
2020-03-07 15:18:25 +01:00
|
|
|
|
2020-03-21 19:28:16 +01:00
|
|
|
_debug "First detect the root zone"
|
|
|
|
if ! _get_root "$fulldomain"; then
|
|
|
|
_err "invalid domain" "$fulldomain"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
_info "die Zone lautet:" "$zone"
|
|
|
|
|
|
|
|
get="$namemaster_api?User=$NM_user&Password=$NM_sha256&Antwort=csv&Typ=ACME&zone=$zone&hostname=$fulldomain&TXT=$txt_value&Action=Auto&Lifetime=3600"
|
|
|
|
|
2020-03-21 19:41:46 +01:00
|
|
|
if ! erg="$(_get "$get")"; then
|
2020-03-21 19:28:16 +01:00
|
|
|
_err "error Adding $fulldomain TXT: $txt_value"
|
2020-03-07 15:18:25 +01:00
|
|
|
return 1
|
2020-03-07 14:55:09 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if _contains "$erg" "Success"; then
|
|
|
|
_info "Success, TXT Added, OK"
|
|
|
|
else
|
2020-03-21 19:28:16 +01:00
|
|
|
_err "error Adding $fulldomain TXT: $txt_value erg: $erg"
|
2020-03-07 14:55:09 +01:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2020-03-21 19:28:16 +01:00
|
|
|
_debug "ok Auto $fulldomain TXT: $txt_value erg: $erg"
|
2020-03-07 14:55:09 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_nm_rm() {
|
|
|
|
|
2020-03-07 15:18:25 +01:00
|
|
|
fulldomain=$1
|
2020-03-21 21:18:25 +01:00
|
|
|
txtvalue=$2
|
|
|
|
_info "TXT enrty in $fulldomain is deleted automatically"
|
|
|
|
_debug fulldomain "$fulldomain"
|
|
|
|
_debug txtvalue "$txtvalue"
|
2020-03-07 14:55:09 +01:00
|
|
|
|
|
|
|
}
|
2020-03-21 19:28:16 +01:00
|
|
|
|
|
|
|
_get_root() {
|
|
|
|
|
|
|
|
domain=$1
|
|
|
|
|
|
|
|
get="$namemaster_api?User=$NM_user&Password=$NM_sha256&Typ=acme&hostname=$domain&Action=getzone&antwort=csv"
|
|
|
|
|
2020-03-21 19:41:46 +01:00
|
|
|
if ! zone="$(_get "$get")"; then
|
2020-03-21 19:28:16 +01:00
|
|
|
_err "error getting Zone"
|
|
|
|
return 1
|
|
|
|
else
|
2020-03-21 19:48:17 +01:00
|
|
|
if _contains "$zone" "hostname not found"; then
|
2020-03-21 19:28:16 +01:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-03-21 19:41:46 +01:00
|
|
|
}
|