]> git.proxmox.com Git - mirror_acme.sh.git/blob - dnsapi/dns_nm.sh
removed the probably last blank line
[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_md5 (your namemaster.de API password_as_md5hash)
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 dns_nm_add() {
18 fulldomain=$1
19 txt_value=$2
20 _info "Using DNS-01 namemaster hook"
21
22 NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
23 NM_md5="${NM_md5:-$(_readaccountconf_mutable NM_md5)}"
24 if [ -z "$NM_user" ] || [ -z "$NM_md5" ]; then
25 NM_user=""
26 NM_md5=""
27 _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_md5 environment variables."
28 return 1
29 fi
30 #save the api user and md5 password to the account conf file.
31 _debug "Save user and hash"
32 _saveaccountconf_mutable NM_user "$NM_user"
33 _saveaccountconf_mutable NM_md5 "$NM_md5"
34
35 zone="$(echo $fulldomain | _egrep_o "[^.]+.[^.]+$")"
36 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"
37 erg="$(_get "$get")"
38
39 if [ "$?" != "0" ]; then
40 _err "error Auto $zone TXT: $txt_value"
41 _err "Error $?"
42 return 1
43 fi
44
45 if _contains "$erg" "Success"; then
46 _info "Success, TXT Added, OK"
47 else
48 _err "error Auto $zone TXT: $txt_value erg: $erg"
49 return 1
50 fi
51
52 _debug "ok Auto $zone TXT: $txt_value erg: $erg"
53 return 0
54 }
55
56 dns_nm_rm() {
57
58 fulldomain=$1
59 txt_value=$2
60
61 NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
62 NM_md5="${NM_md5:-$(_readaccountconf_mutable NM_md5)}"
63 if [ -z "$NM_user" ] || [ -z "$NM_md5" ]; then
64 NM_user=""
65 NM_md5=""
66 _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_md5 environment variables."
67 return 1
68 fi
69
70 zone="$(echo $fulldomain | _egrep_o "[^.]+.[^.]+$")"
71 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"
72 erg="$(_get "$get")"
73 if [ "$?" != "0" ]; then
74 _err "error $action $zone TXT: $txt_value"
75 _err "Error $?"
76 return 1
77 fi
78
79 if _contains "$erg" "Success"; then
80 _info "Success, TXT removed, OK"
81 else
82 _err "error Auto $zone TXT: $txt_value erg: $erg"
83 return 1
84 fi
85
86 _debug "ok Auto $zone TXT: $txt_value erg: $erg"
87 return 0
88
89 }