]> git.proxmox.com Git - mirror_acme.sh.git/blame - dnsapi/dns_doapi.sh
Merge pull request #4531 from NCDGHA/bugfix/issue_4530_fix_http_status_503
[mirror_acme.sh.git] / dnsapi / dns_doapi.sh
CommitLineData
127532c2
TM
1#!/usr/bin/env sh
2
3# Official Let's Encrypt API for do.de / Domain-Offensive
ac9f6e3a 4#
127532c2
TM
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
ac9f6e3a
PDH
7#
8# Provide the required LetsEncrypt token like this:
127532c2
TM
9# DO_LETOKEN="FmD408PdqT1E269gUK57"
10
11DO_API="https://www.do.de/api/letsencrypt"
12
13######## Public functions #####################
14
15#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
16dns_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
5f9b57d3 27 _saveaccountconf_mutable DO_LETOKEN "$DO_LETOKEN"
127532c2 28
ddf77f10 29 _info "Adding TXT record to ${fulldomain}"
127532c2
TM
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"
ddf77f10 35 _err "${response}"
127532c2
TM
36 return 1
37}
38
39dns_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
5f9b57d3 49 _saveaccountconf_mutable DO_LETOKEN "$DO_LETOKEN"
127532c2
TM
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"
ddf77f10 57 _err "${response}"
127532c2
TM
58 return 1
59}