3 # Provider: RackCorp (www.rackcorp.com)
4 # Author: Stephen Dendtler (sdendtler@rackcorp.com)
5 # Report Bugs here: https://github.com/senjoo/acme.sh
6 # Alternate email contact: support@rackcorp.com
8 # You'll need an API key (Portal: ADMINISTRATION -> API)
9 # Set the environment variables as below:
11 # export RACKCORP_APIUUID="UUIDHERE"
12 # export RACKCORP_APISECRET="SECRETHERE"
15 RACKCORP_API_ENDPOINT
="https://api.rackcorp.net/api/rest/v2.4/json.php"
17 ######## Public functions #####################
23 _debug fulldomain
="$fulldomain"
24 _debug txtvalue
="$txtvalue"
26 if ! _rackcorp_validate
; then
30 _debug
"Searching for root zone"
31 if ! _get_root
"$fulldomain"; then
34 _debug _lookup
"$_lookup"
35 _debug _domain
"$_domain"
37 _info
"Creating TXT record."
39 if ! _rackcorp_api dns.record.create
"\"name\":\"$_domain\",\"type\":\"TXT\",\"lookup\":\"$_lookup\",\"data\":\"$txtvalue\",\"ttl\":300"; then
46 #Usage: fulldomain txtvalue
47 #Remove the txt record after validation.
52 _debug fulldomain
="$fulldomain"
53 _debug txtvalue
="$txtvalue"
55 if ! _rackcorp_validate
; then
59 _debug
"Searching for root zone"
60 if ! _get_root
"$fulldomain"; then
63 _debug _lookup
"$_lookup"
64 _debug _domain
"$_domain"
66 _info
"Creating TXT record."
68 if ! _rackcorp_api dns.record.delete
"\"name\":\"$_domain\",\"type\":\"TXT\",\"lookup\":\"$_lookup\",\"data\":\"$txtvalue\""; then
75 #################### Private functions below ##################################
76 #_acme-challenge.domain.com
78 # _lookup=_acme-challenge
84 if ! _rackcorp_api dns.domain.getall
"\"name\":\"$domain\""; then
88 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
89 _debug searchhost
"$h"
91 _err
"Could not find domain for record $domain in RackCorp using the provided credentials"
96 _rackcorp_api dns.domain.getall
"\"exactName\":\"$h\""
98 if _contains
"$response" "\"matches\":1"; then
99 if _contains
"$response" "\"name\":\"$h\""; then
100 _lookup
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
112 _rackcorp_validate
() {
113 RACKCORP_APIUUID
="${RACKCORP_APIUUID:-$(_readaccountconf_mutable RACKCORP_APIUUID)}"
114 if [ -z "$RACKCORP_APIUUID" ]; then
116 _err
"You require a RackCorp API UUID (export RACKCORP_APIUUID=\"<api uuid>\")"
117 _err
"Please login to the portal and create an API key and try again."
121 _saveaccountconf_mutable RACKCORP_APIUUID
"$RACKCORP_APIUUID"
123 RACKCORP_APISECRET
="${RACKCORP_APISECRET:-$(_readaccountconf_mutable RACKCORP_APISECRET)}"
124 if [ -z "$RACKCORP_APISECRET" ]; then
125 RACKCORP_APISECRET
=""
126 _err
"You require a RackCorp API secret (export RACKCORP_APISECRET=\"<api secret>\")"
127 _err
"Please login to the portal and create an API key and try again."
131 _saveaccountconf_mutable RACKCORP_APISECRET
"$RACKCORP_APISECRET"
137 _rackcorpinputdata
=$2
138 _debug cmd
"$_rackcorpcmd $_rackcorpinputdata"
140 export _H1
="Accept: application/json"
141 response
="$(_post "{\"APIUUID
\":\"$RACKCORP_APIUUID\",\"APISECRET
\":\"$RACKCORP_APISECRET\",\"cmd
\":\"$_rackcorpcmd\",$_rackcorpinputdata}" "$RACKCORP_API_ENDPOINT" "" "POST
")"
143 if [ "$?" != "0" ]; then
144 _err
"error $response"
147 _debug2 response
"$response"
148 if _contains
"$response" "\"code\":\"OK\""; then