6 #INWX_Password="password"
8 INWX_Api
="https://api.domrobot.com/xmlrpc/"
10 ######## Public functions #####################
12 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
17 INWX_User
="${INWX_User:-$(_readaccountconf_mutable INWX_User)}"
18 INWX_Password
="${INWX_Password:-$(_readaccountconf_mutable INWX_Password)}"
19 if [ -z "$INWX_User" ] ||
[ -z "$INWX_Password" ]; then
22 _err
"You don't specify inwx user and password yet."
23 _err
"Please create you key and try again."
27 #save the api key and email to the account conf file.
28 _saveaccountconf_mutable INWX_User
"$INWX_User"
29 _saveaccountconf_mutable INWX_Password
"$INWX_Password"
31 _debug
"First detect the root zone"
32 if ! _get_root
"$fulldomain"; then
36 _debug _sub_domain
"$_sub_domain"
37 _debug _domain
"$_domain"
38 _debug
"Getting txt records"
40 printf -v xml_content
'<?xml version="1.0" encoding="UTF-8"?>
42 <methodName>nameserver.info</methodName>
69 </methodCall>' "$_domain" "$_sub_domain"
70 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
72 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
73 _err
"Error could net get txt records"
77 if ! printf "%s" "$response" |
grep "count" -q; then
79 _inwx_add_record
"$_domain" "$_sub_domain" "$txtvalue"
81 _record_id
=$
(printf '%s' "$response" |
sed -nE 's/.*(<member><name>record){1}(.*)(<name>id<\/name><value><int>)([0-9]+){1}.*/\4/p')
82 _info
"Updating record"
83 _inwx_update_record
"$_record_id" "$txtvalue"
94 INWX_User
="${INWX_User:-$(_readaccountconf_mutable INWX_User)}"
95 INWX_Password
="${INWX_Password:-$(_readaccountconf_mutable INWX_Password)}"
96 if [ -z "$INWX_User" ] ||
[ -z "$INWX_Password" ]; then
99 _err
"You don't specify inwx user and password yet."
100 _err
"Please create you key and try again."
104 #save the api key and email to the account conf file.
105 _saveaccountconf_mutable INWX_User
"$INWX_User"
106 _saveaccountconf_mutable INWX_Password
"$INWX_Password"
108 _debug
"First detect the root zone"
109 if ! _get_root
"$fulldomain"; then
110 _err
"invalid domain"
113 _debug _sub_domain
"$_sub_domain"
114 _debug _domain
"$_domain"
116 _debug
"Getting txt records"
118 printf -v xml_content
'<?xml version="1.0" encoding="UTF-8"?>
120 <methodName>nameserver.info</methodName>
147 </methodCall>' "$_domain" "$_sub_domain"
148 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
150 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
151 _err
"Error could not get txt records"
155 if ! printf "%s" "$response" |
grep "count" -q; then
156 _info
"Do not need to delete record"
158 _record_id
=$
(printf '%s' "$response" |
sed -nE 's/.*(<member><name>record){1}(.*)(<name>id<\/name><value><int>)([0-9]+){1}.*/\4/p')
159 _info
"Deleting record"
160 _inwx_delete_record
"$_record_id"
165 #################### Private functions below ##################################
169 printf -v xml_content
'<?xml version="1.0" encoding="UTF-8"?>
171 <methodName>account.login</methodName>
192 </methodCall>' $INWX_User $INWX_Password
194 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
196 printf "Cookie: %s" "$(grep "domrobot
=" "$HTTP_HEADER" | grep "^Set-Cookie
:" | _tail_n 1 | _egrep_o 'domrobot=[^;]*;' | tr -d ';')"
210 printf -v xml_content
'<?xml version="1.0" encoding="UTF-8"?>
212 <methodName>nameserver.list</methodName>
215 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
217 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
224 if _contains
"$response" "$h"; then
225 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
236 _inwx_delete_record
() {
238 printf -v xml_content
'<?xml version="1.0" encoding="UTF-8"?>
240 <methodName>nameserver.deleteRecord</methodName>
255 </methodCall>' "$record_id"
257 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
259 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
267 _inwx_update_record
() {
270 printf -v xml_content
'<?xml version="1.0" encoding="UTF-8"?>
272 <methodName>nameserver.updateRecord</methodName>
293 </methodCall>' "$txtval" "$record_id"
295 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
297 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
311 printf -v xml_content
'<?xml version="1.0" encoding="UTF-8"?>
313 <methodName>nameserver.createRecord</methodName>
346 </methodCall>' "$domain" "$txtval" "$sub_domain"
348 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
350 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then