6 #INWX_Password="password"
10 # - oathtool (When using 2 Factor Authentication)
12 INWX_Api
="https://api.domrobot.com/xmlrpc/"
14 ######## Public functions #####################
16 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
21 INWX_User
="${INWX_User:-$(_readaccountconf_mutable INWX_User)}"
22 INWX_Password
="${INWX_Password:-$(_readaccountconf_mutable INWX_Password)}"
23 INWX_Shared_Secret
="${INWX_Shared_Secret:-$(_readaccountconf_mutable INWX_Shared_Secret)}"
24 if [ -z "$INWX_User" ] ||
[ -z "$INWX_Password" ]; then
27 _err
"You don't specify inwx user and password yet."
28 _err
"Please create you key and try again."
32 #save the api key and email to the account conf file.
33 _saveaccountconf_mutable INWX_User
"$INWX_User"
34 _saveaccountconf_mutable INWX_Password
"$INWX_Password"
35 _saveaccountconf_mutable INWX_Shared_Secret
"$INWX_Shared_Secret"
37 _debug
"First detect the root zone"
38 if ! _get_root
"$fulldomain"; then
42 _debug _sub_domain
"$_sub_domain"
43 _debug _domain
"$_domain"
46 _inwx_add_record
"$_domain" "$_sub_domain" "$txtvalue"
56 INWX_User
="${INWX_User:-$(_readaccountconf_mutable INWX_User)}"
57 INWX_Password
="${INWX_Password:-$(_readaccountconf_mutable INWX_Password)}"
58 INWX_Shared_Secret
="${INWX_Shared_Secret:-$(_readaccountconf_mutable INWX_Shared_Secret)}"
59 if [ -z "$INWX_User" ] ||
[ -z "$INWX_Password" ]; then
62 _err
"You don't specify inwx user and password yet."
63 _err
"Please create you key and try again."
67 _debug
"First detect the root zone"
68 if ! _get_root
"$fulldomain"; then
72 _debug _sub_domain
"$_sub_domain"
73 _debug _domain
"$_domain"
75 _debug
"Getting txt records"
77 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
79 <methodName>nameserver.info</methodName>
106 </methodCall>' "$_domain" "$_sub_domain")
107 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
109 if ! _contains
"$response" "Command completed successfully"; then
110 _err
"Error could not get txt records"
114 if ! printf "%s" "$response" |
grep "count" >/dev
/null
; then
115 _info
"Do not need to delete record"
117 _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]+')
118 _info
"Deleting record"
119 _inwx_delete_record
"$_record_id"
124 #################### Private functions below ##################################
128 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
130 <methodName>account.login</methodName>
151 </methodCall>' $INWX_User $INWX_Password)
153 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
154 _H1
=$
(printf "Cookie: %s" "$(grep "domrobot
=" "$HTTP_HEADER" | grep "^Set-Cookie
:" | _tail_n 1 | _egrep_o 'domrobot=[^;]*;' | tr -d ';')")
157 #https://github.com/inwx/php-client/blob/master/INWX/Domrobot.php#L71
158 if _contains
"$response" "<member><name>code</name><value><int>1000</int></value></member>" \
159 && _contains
"$response" "<member><name>tfa</name><value><string>GOOGLE-AUTH</string></value></member>"; then
160 if [ -z "$INWX_Shared_Secret" ]; then
161 _err
"Mobile TAN detected."
162 _err
"Please define a shared secret."
166 if ! _exists oathtool
; then
167 _err
"Please install oathtool to use 2 Factor Authentication."
172 tan
="$(oathtool --base32 --totp "${INWX_Shared_Secret}" 2>/dev/null)"
174 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
176 <methodName>account.unlock</methodName>
191 </methodCall>' "$tan")
193 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
208 xml_content
='<?xml version="1.0" encoding="UTF-8"?>
210 <methodName>nameserver.list</methodName>
213 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
215 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
222 if _contains
"$response" "$h"; then
223 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
234 _inwx_delete_record
() {
236 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
238 <methodName>nameserver.deleteRecord</methodName>
253 </methodCall>' "$record_id")
255 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
257 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
265 _inwx_update_record
() {
268 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
270 <methodName>nameserver.updateRecord</methodName>
291 </methodCall>' "$txtval" "$record_id")
293 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
295 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then
309 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
311 <methodName>nameserver.createRecord</methodName>
344 </methodCall>' "$domain" "$txtval" "$sub_domain")
346 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
348 if ! printf "%s" "$response" |
grep "Command completed successfully" >/dev
/null
; then