]>
git.proxmox.com Git - mirror_acme.sh.git/blob - dnsapi/dns_mydevil.sh
3 # MyDevil.net API (2019-02-03)
5 # MyDevil.net already supports automatic Let's Encrypt certificates,
6 # except for wildcard domains.
8 # This script depends on `devil` command that MyDevil.net provides,
9 # which means that it works only on server side.
11 # Author: Marcin Konicki <https://ahwayakchih.neoni.net>
13 ######## Public functions #####################
15 #Usage: dns_mydevil_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
21 if ! _exists
"devil"; then
22 _err
"Could not find 'devil' command."
28 domain
=$
(mydevil_get_domain
"$fulldomain")
29 if [ -z "$domain" ]; then
30 _err
"Invalid domain name: could not find root domain of $fulldomain."
34 # No need to check if record name exists, `devil` always adds new record.
35 # In worst case scenario, we end up with multiple identical records.
37 _info
"Adding $fulldomain record for domain $domain"
38 if devil dns add
"$domain" "$fulldomain" TXT
"$txtvalue"; then
39 _info
"Successfully added TXT record, ready for validation."
42 _err
"Unable to add DNS record."
47 #Usage: fulldomain txtvalue
48 #Remove the txt record after validation.
54 if ! _exists
"devil"; then
55 _err
"Could not find 'devil' command."
61 domain
=$
(mydevil_get_domain
"$fulldomain")
62 if [ -z "$domain" ]; then
63 _err
"Invalid domain name: could not find root domain of $fulldomain."
67 # catch one or more numbers
69 # catch one or more whitespace
70 w
=$
(printf '[\t ][\t ]*')
71 # catch anything, except newline
73 # filter to make sure we do not delete other records
74 validRecords
="^${num}${w}${fulldomain}${w}TXT${w}${any}${txtvalue}$"
75 for id
in $
(devil dns list
"$domain" |
tail -n+2 |
grep "${validRecords}" | cut
-w -s -f 1); do
76 _info
"Removing record $id from domain $domain"
77 echo "y" | devil dns del
"$domain" "$id" || _err
"Could not remove DNS record."
81 #################### Private functions below ##################################
83 # Usage: domain=$(mydevil_get_domain "_acme-challenge.www.domain.com" || _err "Invalid domain name")
85 mydevil_get_domain
() {
89 for domain
in $
(devil dns list | cut
-w -s -f 1 |
tail -n+2); do
90 _debug
"Checking domain: $domain"
91 if _endswith
"$fulldomain" "$domain"; then
92 _debug
"Fulldomain '$fulldomain' matches '$domain'"
93 printf -- "%s" "$domain"