]> git.proxmox.com Git - mirror_acme.sh.git/blob - dnsapi/dns_doapi.sh
Merge pull request #4658 from Justman10000/master
[mirror_acme.sh.git] / dnsapi / dns_doapi.sh
1 #!/usr/bin/env sh
2
3 # Official Let's Encrypt API for do.de / Domain-Offensive
4 #
5 # This is different from the dns_do adapter, because dns_do is only usable for enterprise customers
6 # This API is also available to private customers/individuals
7 #
8 # Provide the required LetsEncrypt token like this:
9 # DO_LETOKEN="FmD408PdqT1E269gUK57"
10
11 DO_API="https://www.do.de/api/letsencrypt"
12
13 ######## Public functions #####################
14
15 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
16 dns_doapi_add() {
17 fulldomain=$1
18 txtvalue=$2
19
20 DO_LETOKEN="${DO_LETOKEN:-$(_readaccountconf_mutable DO_LETOKEN)}"
21 if [ -z "$DO_LETOKEN" ]; then
22 DO_LETOKEN=""
23 _err "You didn't configure a do.de API token yet."
24 _err "Please set DO_LETOKEN and try again."
25 return 1
26 fi
27 _saveaccountconf_mutable DO_LETOKEN "$DO_LETOKEN"
28
29 _info "Adding TXT record to ${fulldomain}"
30 response="$(_get "$DO_API?token=$DO_LETOKEN&domain=${fulldomain}&value=${txtvalue}")"
31 if _contains "${response}" 'success'; then
32 return 0
33 fi
34 _err "Could not create resource record, check logs"
35 _err "${response}"
36 return 1
37 }
38
39 dns_doapi_rm() {
40 fulldomain=$1
41
42 DO_LETOKEN="${DO_LETOKEN:-$(_readaccountconf_mutable DO_LETOKEN)}"
43 if [ -z "$DO_LETOKEN" ]; then
44 DO_LETOKEN=""
45 _err "You didn't configure a do.de API token yet."
46 _err "Please set DO_LETOKEN and try again."
47 return 1
48 fi
49 _saveaccountconf_mutable DO_LETOKEN "$DO_LETOKEN"
50
51 _info "Deleting resource record $fulldomain"
52 response="$(_get "$DO_API?token=$DO_LETOKEN&domain=${fulldomain}&action=delete")"
53 if _contains "${response}" 'success'; then
54 return 0
55 fi
56 _err "Could not delete resource record, check logs"
57 _err "${response}"
58 return 1
59 }