Skip to content

Commit 80ad62f

Browse files
authored
Merge pull request #3208 from cusae/dev
Add BookMyName API support
2 parents a7455d7 + ee50f25 commit 80ad62f

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

dnsapi/dns_bookmyname.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env sh
2+
3+
#Here is a sample custom api script.
4+
#This file name is "dns_bookmyname.sh"
5+
#So, here must be a method dns_bookmyname_add()
6+
#Which will be called by acme.sh to add the txt record to your api system.
7+
#returns 0 means success, otherwise error.
8+
#
9+
#Author: Neilpang
10+
#Report Bugs here: https://github.com/acmesh-official/acme.sh
11+
#
12+
######## Public functions #####################
13+
14+
# Please Read this guide first: https://github.com/acmesh-official/acme.sh/wiki/DNS-API-Dev-Guide
15+
16+
# BookMyName urls:
17+
# https://BOOKMYNAME_USERNAME:[email protected]/dyndns/?hostname=_acme-challenge.domain.tld&type=txt&ttl=300&do=add&value="XXXXXXXX"'
18+
# https://BOOKMYNAME_USERNAME:[email protected]/dyndns/?hostname=_acme-challenge.domain.tld&type=txt&ttl=300&do=remove&value="XXXXXXXX"'
19+
20+
# Output:
21+
#good: update done, cid 123456, domain id 456789, type txt, ip XXXXXXXX
22+
#good: remove done 1, cid 123456, domain id 456789, ttl 300, type txt, ip XXXXXXXX
23+
24+
# Be careful, BMN DNS servers can be slow to pick up changes; using dnssleep is thus advised.
25+
26+
# Usage:
27+
# export BOOKMYNAME_USERNAME="ABCDE-FREE"
28+
# export BOOKMYNAME_PASSWORD="MyPassword"
29+
# /usr/local/ssl/acme.sh/acme.sh --dns dns_bookmyname --dnssleep 600 --issue -d domain.tld
30+
31+
#Usage: dns_bookmyname_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
32+
dns_bookmyname_add() {
33+
fulldomain=$1
34+
txtvalue=$2
35+
_info "Using bookmyname"
36+
_debug fulldomain "$fulldomain"
37+
_debug txtvalue "$txtvalue"
38+
39+
BOOKMYNAME_USERNAME="${BOOKMYNAME_USERNAME:-$(_readaccountconf_mutable BOOKMYNAME_USERNAME)}"
40+
BOOKMYNAME_PASSWORD="${BOOKMYNAME_PASSWORD:-$(_readaccountconf_mutable BOOKMYNAME_PASSWORD)}"
41+
42+
if [ -z "$BOOKMYNAME_USERNAME" ] || [ -z "$BOOKMYNAME_PASSWORD" ]; then
43+
BOOKMYNAME_USERNAME=""
44+
BOOKMYNAME_PASSWORD=""
45+
_err "You didn't specify BookMyName username and password yet."
46+
_err "Please specify them and try again."
47+
return 1
48+
fi
49+
50+
#save the credentials to the account conf file.
51+
_saveaccountconf_mutable BOOKMYNAME_USERNAME "$BOOKMYNAME_USERNAME"
52+
_saveaccountconf_mutable BOOKMYNAME_PASSWORD "$BOOKMYNAME_PASSWORD"
53+
54+
uri="https://${BOOKMYNAME_USERNAME}:${BOOKMYNAME_PASSWORD}@www.bookmyname.com/dyndns/"
55+
data="?hostname=${fulldomain}&type=TXT&ttl=300&do=add&value=${txtvalue}"
56+
result="$(_get "${uri}${data}")"
57+
_debug "Result: $result"
58+
59+
if ! _startswith "$result" 'good: update done, cid '; then
60+
_err "Can't add $fulldomain"
61+
return 1
62+
fi
63+
64+
}
65+
66+
#Usage: fulldomain txtvalue
67+
#Remove the txt record after validation.
68+
dns_bookmyname_rm() {
69+
fulldomain=$1
70+
txtvalue=$2
71+
_info "Using bookmyname"
72+
_debug fulldomain "$fulldomain"
73+
_debug txtvalue "$txtvalue"
74+
75+
BOOKMYNAME_USERNAME="${BOOKMYNAME_USERNAME:-$(_readaccountconf_mutable BOOKMYNAME_USERNAME)}"
76+
BOOKMYNAME_PASSWORD="${BOOKMYNAME_PASSWORD:-$(_readaccountconf_mutable BOOKMYNAME_PASSWORD)}"
77+
78+
uri="https://${BOOKMYNAME_USERNAME}:${BOOKMYNAME_PASSWORD}@www.bookmyname.com/dyndns/"
79+
data="?hostname=${fulldomain}&type=TXT&ttl=300&do=remove&value=${txtvalue}"
80+
result="$(_get "${uri}${data}")"
81+
_debug "Result: $result"
82+
83+
if ! _startswith "$result" 'good: remove done 1, cid '; then
84+
_info "Can't remove $fulldomain"
85+
fi
86+
87+
}
88+
89+
#################### Private functions below ##################################

0 commit comments

Comments
 (0)