4 #RAGE4_TOKEN="sdfsdfsdfljlbjkljlkjsdfoiwje"
6 #RAGE4_USERNAME="xxxx@sss.com"
8 RAGE4_Api
="https://rage4.com/rapi/"
10 ######## Public functions #####################
12 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
17 unquotedtxtvalue
=$
(echo "$txtvalue" |
tr -d \")
19 RAGE4_USERNAME
="${RAGE4_USERNAME:-$(_readaccountconf_mutable RAGE4_USERNAME)}"
20 RAGE4_TOKEN
="${RAGE4_TOKEN:-$(_readaccountconf_mutable RAGE4_TOKEN)}"
22 if [ -z "$RAGE4_USERNAME" ] ||
[ -z "$RAGE4_TOKEN" ]; then
25 _err
"You didn't specify a Rage4 api token and username yet."
29 #save the api key and email to the account conf file.
30 _saveaccountconf_mutable RAGE4_USERNAME
"$RAGE4_USERNAME"
31 _saveaccountconf_mutable RAGE4_TOKEN
"$RAGE4_TOKEN"
33 _debug
"First detect the root zone"
34 if ! _get_root
"$fulldomain"; then
38 _debug _domain_id
"$_domain_id"
40 _rage4_rest
"createrecord/?id=$_domain_id&name=$fulldomain&content=$unquotedtxtvalue&type=TXT&active=true&ttl=1"
49 RAGE4_USERNAME
="${RAGE4_USERNAME:-$(_readaccountconf_mutable RAGE4_USERNAME)}"
50 RAGE4_TOKEN
="${RAGE4_TOKEN:-$(_readaccountconf_mutable RAGE4_TOKEN)}"
52 _debug
"First detect the root zone"
53 if ! _get_root
"$fulldomain"; then
57 _debug _domain_id
"$_domain_id"
59 _debug
"Getting txt records"
60 _rage4_rest
"getrecords/?id=${_domain_id}"
62 _record_id
=$
(echo "$response" |
sed -rn 's/.*"id":([[:digit:]]+)[^\}]*'"$txtvalue"'.*/\1/p')
63 _rage4_rest
"deleterecord/?id=${_record_id}"
67 #################### Private functions below ##################################
68 #_acme-challenge.www.domain.com
71 # _domain_id=sdjkglgdfewsdfg
75 if ! _rage4_rest
"getdomains"; then
78 _debug _get_root_domain
"$domain"
80 for line
in $
(echo "$response" |
tr '}' '\n'); do
81 __domain
=$
(echo "$line" |
sed -rn 's/.*"name":"([^"]*)",.*/\1/p')
82 __domain_id
=$
(echo "$line" |
sed -rn 's/.*"id":([^,]*),.*/\1/p')
83 if [ "$domain" != "${domain%"$__domain"*}" ]; then
84 _domain_id
="$__domain_id"
89 if [ -z "$_domain_id" ]; then
100 username_trimmed
=$
(echo "$RAGE4_USERNAME" |
tr -d '"')
101 token_trimmed
=$
(echo "$RAGE4_TOKEN" |
tr -d '"')
102 auth
=$
(printf '%s:%s' "$username_trimmed" "$token_trimmed" | _base64
)
104 export _H1
="Content-Type: application/json"
105 export _H2
="Authorization: Basic $auth"
107 response
="$(_get "$RAGE4_Api$ep")"
109 if [ "$?" != "0" ]; then
113 _debug2 response
"$response"