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 if [ -z "$INWX_User" ] ||
[ -z "$INWX_Password" ]; then
61 _err
"You don't specify inwx user and password yet."
62 _err
"Please create you key and try again."
66 #save the api key and email to the account conf file.
67 _saveaccountconf_mutable INWX_User
"$INWX_User"
68 _saveaccountconf_mutable INWX_Password
"$INWX_Password"
70 _debug
"First detect the root zone"
71 if ! _get_root
"$fulldomain"; then
75 _debug _sub_domain
"$_sub_domain"
76 _debug _domain
"$_domain"
78 _debug
"Getting txt records"
80 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
82 <methodName>nameserver.info</methodName>
109 </methodCall>' "$_domain" "$_sub_domain")
110 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
112 if ! _contains
"$response" "Command completed successfully"; then
113 _err
"Error could not get txt records"
117 if ! printf "%s" "$response" |
grep "count" >/dev
/null
; then
118 _info
"Do not need to delete record"
120 _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]+')
121 _info
"Deleting record"
122 _inwx_delete_record
"$_record_id"
127 #################### Private functions below ##################################
131 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
133 <methodName>account.login</methodName>
154 </methodCall>' $INWX_User $INWX_Password)
156 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
157 _H1
=$
(printf "Cookie: %s" "$(grep "domrobot
=" "$HTTP_HEADER" | grep "^Set-Cookie
:" | _tail_n 1 | _egrep_o 'domrobot=[^;]*;' | tr -d ';')")
160 #https://github.com/inwx/php-client/blob/master/INWX/Domrobot.php#L71
161 if _contains
"$response" "tfa"; then
162 if [ -z "$INWX_Shared_Secret" ]; then
163 _err
"Mobile TAN detected."
164 _err
"Please define a shared secret."
168 if ! _exists oathtool
; then
169 _err
"Please install oathtool to use 2 Factor Authentication."
174 tan
="$(oathtool --base32 --totp "${INWX_Shared_Secret}" 2>/dev/null)"
176 xml_content
=$
(printf '<?xml version="1.0" encoding="UTF-8"?>
178 <methodName>account.unlock</methodName>
193 </methodCall>' "$tan")
195 response
="$(_post "$xml_content" "$INWX_Api" "" "POST
")"
210 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 xml_content
=$
(printf '<?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 xml_content
=$
(printf '<?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 xml_content
=$
(printf '<?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