3 # Joker.com API for acme.sh
5 # This script adds the necessary TXT record to a domain in Joker.com.
7 # You must activate Dynamic DNS in Joker.com DNS configuration first.
8 # Username and password below refer to Dynamic DNS authentication,
9 # not your Joker.com login credentials.
10 # See: https://joker.com/faq/content/11/427/en/what-is-dynamic-dns-dyndns.html
12 # NOTE: This script does not support wildcard certificates, because
13 # Joker.com API does not support adding two TXT records with the same
14 # subdomain. Adding the second record will overwrite the first one.
15 # See: https://joker.com/faq/content/6/496/en/let_s-encrypt-support.html
16 # "... this request will replace all TXT records for the specified
17 # label by the provided content"
19 # Author: aattww (https://github.com/aattww/)
21 # JOKER_USERNAME="xxxx"
22 # JOKER_PASSWORD="xxxx"
24 JOKER_API
="https://svc.joker.com/nic/replace"
26 ######## Public functions #####################
28 #Usage: dns_joker_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
33 JOKER_USERNAME
="${JOKER_USERNAME:-$(_readaccountconf_mutable JOKER_USERNAME)}"
34 JOKER_PASSWORD
="${JOKER_PASSWORD:-$(_readaccountconf_mutable JOKER_PASSWORD)}"
36 if [ -z "$JOKER_USERNAME" ] ||
[ -z "$JOKER_PASSWORD" ]; then
37 _err
"No Joker.com username and password specified."
41 _saveaccountconf_mutable JOKER_USERNAME
"$JOKER_USERNAME"
42 _saveaccountconf_mutable JOKER_PASSWORD
"$JOKER_PASSWORD"
44 if ! _get_root
"$fulldomain"; then
49 _info
"Adding TXT record"
50 if _joker_rest
"username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$_domain&label=$_sub_domain&type=TXT&value=$txtvalue"; then
51 if _startswith
"$response" "OK"; then
56 _err
"Error adding TXT record."
65 JOKER_USERNAME
="${JOKER_USERNAME:-$(_readaccountconf_mutable JOKER_USERNAME)}"
66 JOKER_PASSWORD
="${JOKER_PASSWORD:-$(_readaccountconf_mutable JOKER_PASSWORD)}"
68 if ! _get_root
"$fulldomain"; then
73 _info
"Removing TXT record"
74 # TXT record is removed by setting its value to empty.
75 if _joker_rest
"username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$_domain&label=$_sub_domain&type=TXT&value="; then
76 if _startswith
"$response" "OK"; then
81 _err
"Error removing TXT record."
85 #################### Private functions below ##################################
86 #_acme-challenge.www.domain.com
88 # _sub_domain=_acme-challenge.www
94 h
=$
(printf "%s" "$fulldomain" | cut
-d .
-f $i-100)
100 # Try to remove a test record. With correct root domain, username and password this will return "OK: ..." regardless
101 # of record in question existing or not.
102 if _joker_rest
"username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$h&label=jokerTXTUpdateTest&type=TXT&value="; then
103 if _startswith
"$response" "OK"; then
104 _sub_domain
="$(echo "$fulldomain" | sed "s
/\\.
$h\$
//")"
113 _debug
"Root domain not found"
121 response
="$(_post "$data" "$JOKER_API" "" "POST
")"
123 if [ "$?" != "0" ]; then
127 _debug response
"$response"