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 # Report bugs to https://github.com/acmesh-official/acme.sh/issues/2840
23 # JOKER_USERNAME="xxxx"
24 # JOKER_PASSWORD="xxxx"
26 JOKER_API
="https://svc.joker.com/nic/replace"
28 ######## Public functions #####################
30 #Usage: dns_joker_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
35 JOKER_USERNAME
="${JOKER_USERNAME:-$(_readaccountconf_mutable JOKER_USERNAME)}"
36 JOKER_PASSWORD
="${JOKER_PASSWORD:-$(_readaccountconf_mutable JOKER_PASSWORD)}"
38 if [ -z "$JOKER_USERNAME" ] ||
[ -z "$JOKER_PASSWORD" ]; then
39 _err
"No Joker.com username and password specified."
43 _saveaccountconf_mutable JOKER_USERNAME
"$JOKER_USERNAME"
44 _saveaccountconf_mutable JOKER_PASSWORD
"$JOKER_PASSWORD"
46 if ! _get_root
"$fulldomain"; then
51 _info
"Adding TXT record"
52 if _joker_rest
"username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$_domain&label=$_sub_domain&type=TXT&value=$txtvalue"; then
53 if _startswith
"$response" "OK"; then
58 _err
"Error adding TXT record."
67 JOKER_USERNAME
="${JOKER_USERNAME:-$(_readaccountconf_mutable JOKER_USERNAME)}"
68 JOKER_PASSWORD
="${JOKER_PASSWORD:-$(_readaccountconf_mutable JOKER_PASSWORD)}"
70 if ! _get_root
"$fulldomain"; then
75 _info
"Removing TXT record"
76 # TXT record is removed by setting its value to empty.
77 if _joker_rest
"username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$_domain&label=$_sub_domain&type=TXT&value="; then
78 if _startswith
"$response" "OK"; then
83 _err
"Error removing TXT record."
87 #################### Private functions below ##################################
88 #_acme-challenge.www.domain.com
90 # _sub_domain=_acme-challenge.www
96 h
=$
(printf "%s" "$fulldomain" | cut
-d .
-f $i-100)
102 # Try to remove a test record. With correct root domain, username and password this will return "OK: ..." regardless
103 # of record in question existing or not.
104 if _joker_rest
"username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$h&label=jokerTXTUpdateTest&type=TXT&value="; then
105 if _startswith
"$response" "OK"; then
106 _sub_domain
="$(echo "$fulldomain" | sed "s
/\\.
$h\$
//")"
115 _debug
"Root domain not found"
123 if ! response
="$(_post "$data" "$JOKER_API" "" "POST
")"; then
127 _debug response
"$response"