]> git.proxmox.com Git - mirror_acme.sh.git/blob - dnsapi/dns_nm.sh
Merge branch 'acmesh-official:dev' into dev
[mirror_acme.sh.git] / dnsapi / dns_nm.sh
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)
9 # - $NM_sha256 (your namemaster.de API password_as_sha256hash)
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
17 namemaster_api="https://namemaster.de/api/api.php"
18
19 dns_nm_add() {
20 fulldomain=$1
21 txt_value=$2
22 _info "Using DNS-01 namemaster hook"
23
24 NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
25 NM_sha256="${NM_sha256:-$(_readaccountconf_mutable NM_sha256)}"
26 if [ -z "$NM_user" ] || [ -z "$NM_sha256" ]; then
27 NM_user=""
28 NM_sha256=""
29 _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_sha256 environment variables."
30 return 1
31 fi
32 #save the api user and sha256 password to the account conf file.
33 _debug "Save user and hash"
34 _saveaccountconf_mutable NM_user "$NM_user"
35 _saveaccountconf_mutable NM_sha256 "$NM_sha256"
36
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
47 if ! erg="$(_get "$get")"; then
48 _err "error Adding $fulldomain TXT: $txt_value"
49 return 1
50 fi
51
52 if _contains "$erg" "Success"; then
53 _info "Success, TXT Added, OK"
54 else
55 _err "error Adding $fulldomain TXT: $txt_value erg: $erg"
56 return 1
57 fi
58
59 _debug "ok Auto $fulldomain TXT: $txt_value erg: $erg"
60 return 0
61 }
62
63 dns_nm_rm() {
64
65 fulldomain=$1
66 txtvalue=$2
67 _info "TXT enrty in $fulldomain is deleted automatically"
68 _debug fulldomain "$fulldomain"
69 _debug txtvalue "$txtvalue"
70
71 }
72
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
79 if ! zone="$(_get "$get")"; then
80 _err "error getting Zone"
81 return 1
82 else
83 if _contains "$zone" "hostname not found"; then
84 return 1
85 fi
86 fi
87
88 }