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