]> git.proxmox.com Git - mirror_acme.sh.git/blame - dnsapi/dns_nm.sh
fixing travis-ci warnings SC2086: Double quote to prevent globbing and word splitting.
[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)
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
17dns_nm_add() {
18 fulldomain=$1
19 txt_value=$2
20 _info "Using DNS-01 namemaster hook"
30416f54 21
f21ef0d2
T
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=""
30416f54 27 _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_md5 environment variables."
f21ef0d2
T
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"
30416f54 34
3c79bb77 35 zone="$(echo "$fulldomain" | _egrep_o "[^.]+.[^.]+$")"
f21ef0d2 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"
f21ef0d2 37
20702d26 38 if ! erg="$(_get "$get")"; then
7d7e9501 39 _err "error Deleting $zone TXT: $txt_value"
30416f54 40 return 1
f21ef0d2
T
41 fi
42
43 if _contains "$erg" "Success"; then
44 _info "Success, TXT Added, OK"
45 else
142ca58d 46 _err "error Adding $zone TXT: $txt_value erg: $erg"
f21ef0d2
T
47 return 1
48 fi
49
3b01bf7b 50 _debug "ok Auto $zone TXT: $txt_value erg: $erg"
f21ef0d2 51 return 0
d8dbb859 52
f21ef0d2
T
53}
54
55dns_nm_rm() {
56
30416f54
T
57 fulldomain=$1
58 txt_value=$2
f21ef0d2
T
59
60 NM_user="${NM_user:-$(_readaccountconf_mutable NM_user)}"
61 NM_md5="${NM_md5:-$(_readaccountconf_mutable NM_md5)}"
62 if [ -z "$NM_user" ] || [ -z "$NM_md5" ]; then
63 NM_user=""
64 NM_md5=""
30416f54 65 _err "No auth details provided. Please set user credentials using the \$NM_user and \$NM_md5 environment variables."
f21ef0d2
T
66 return 1
67 fi
68
3c79bb77 69 zone="$(echo "$fulldomain" | _egrep_o "[^.]+.[^.]+$")"
f21ef0d2 70 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"
e1e1ee31 71
20702d26 72 if ! erg="$(_get "$get")"; then
142ca58d 73 _err "error Deleting $zone TXT: $txt_value"
f21ef0d2
T
74 return 1
75 fi
76
30416f54
T
77 if _contains "$erg" "Success"; then
78 _info "Success, TXT removed, OK"
79 else
3b01bf7b 80 _err "error Auto $zone TXT: $txt_value erg: $erg"
30416f54
T
81 return 1
82 fi
f21ef0d2 83
3b01bf7b 84 _debug "ok Auto $zone TXT: $txt_value erg: $erg"
30416f54 85 return 0
f21ef0d2 86
f21ef0d2 87}