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"
40 _inwx_add_record
"$_domain" "$_sub_domain" "$txtvalue"
50 INWX_User
="${INWX_User:-$(_readaccountconf_mutable INWX_User)}"
51 INWX_Password
="${INWX_Password:-$(_readaccountconf_mutable INWX_Password)}"
52 if [ -z "$INWX_User" ] ||
[ -z "$INWX_Password" ]; then
55 _err
"You don't specify inwx user and password yet."
56 _err
"Please create you key and try again."
60 #save the api key and email to the account conf file.
61 _saveaccountconf_mutable INWX_User
"$INWX_User"
62 _saveaccountconf_mutable INWX_Password
"$INWX_Password"
64 _debug
"First detect the root zone"
65 if ! _get_root
"$fulldomain"; then
69 _debug _sub_domain
"$_sub_domain"
70 _debug _domain
"$_domain"
72 _debug
"Getting txt records"
74 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
76 <methodName>nameserver.info</methodName>
103 </methodCall>' "$_domain" "$_sub_domain")
104 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
106 if ! _contains
"$response" "Command completed successfully"; then
107 _err
"Error could not get txt records"
111 if ! printf "%s" "$response" |
grep "count" >/dev
/null
; then
112 _info
"Do not need to delete record"
114 _record_id
=$
(printf '%s' "$response" | _egrep_o
'.*(<member><name>record){1}(.*)([0-9]+){1}' | _egrep_o
'<name>id<\/name><value><int>[0-9]+' | _egrep_o
'[0-9]+')
115 _info
"Deleting record"
116 _inwx_delete_record
"$_record_id"
121 #################### Private functions below ##################################
125 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
127 <methodName>account.login</methodName>
148 </methodCall>' $INWX_User $INWX_Password)
150 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
152 printf "Cookie: %s" "$(grep "domrobot
=" "$HTTP_HEADER" | grep "^Set-Cookie
:" | _tail_n 1 | _egrep_o 'domrobot=[^;]*;' | tr -d ';')"
166 xml_content
='<?xml version="1.0" encoding="UTF-8"?>
168 <methodName>nameserver.list</methodName>
171 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
173 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
180 if _contains
"$response" "$h"; then
181 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
192 _inwx_delete_record
() {
194 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
196 <methodName>nameserver.deleteRecord</methodName>
211 </methodCall>' "$record_id")
213 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
215 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
223 _inwx_update_record
() {
226 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
228 <methodName>nameserver.updateRecord</methodName>
249 </methodCall>' "$txtval" "$record_id")
251 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
253 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
267 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
269 <methodName>nameserver.createRecord</methodName>
302 </methodCall>' "$domain" "$txtval" "$sub_domain")
304 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
306 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then