4 #Report Bugs here: https://github.com/RhinoLance/acme.sh
7 #define the api endpoint
8 DH_API_ENDPOINT
="https://api.dreamhost.com/"
11 ######## Public functions #####################
13 #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
18 if ! validate
"$fulldomain" "$txtvalue"; then
22 querystring
="key=$DH_API_KEY&cmd=dns-add_record&record=$fulldomain&type=TXT&value=$txtvalue"
23 if ! submit
"$querystring"; then
30 #Usage: fulldomain txtvalue
31 #Remove the txt record after validation.
36 if ! validate
"$fulldomain" "$txtvalue"; then
40 querystring
="key=$DH_API_KEY&cmd=dns-remove_record&record=$fulldomain&type=TXT&value=$txtvalue"
41 if ! submit
"$querystring"; then
48 #################### Private functions below ##################################
50 #send the command to the api endpoint.
54 url
="$DH_API_ENDPOINT?$querystring"
58 if ! response
="$(_get "$url")"; then
64 message
="$(echo "$response" | _egrep_o "\"Message
\":\"[^
\"]*\"" | cut -d : -f 2 | tr -d \")"
65 if [ -n "$message" ]; then
71 _debug response
"$response"
76 #check that we have a valid API Key
81 _info
"Using dreamhost"
82 _debug fulldomain
"$fulldomain"
83 _debug txtvalue
"$txtvalue"
85 #retrieve the API key from the environment variable if it exists, otherwise look for a saved key.
86 DH_API_KEY
="${DH_API_KEY:-$(_readaccountconf_mutable DH_API_KEY)}"
88 if [ -z "$DH_API_KEY" ]; then
90 _err
"You didn't specify the DreamHost api key yet (export DH_API_KEY=\"<api key>\")"
91 _err
"Please login to your control panel, create a key and try again."
95 #save the api key to the account conf file.
96 _saveaccountconf_mutable DH_API_KEY
"$DH_API_KEY"