8 # CONTACT: main@lugico.de
10 [ -z "$CURL" ] && [ -z "$CURL_SSL" ] && write_log
14 "one.com communication require cURL with SSL support. Please install"
11 [ -z "$domain" ] && write_log
14 "Service section not configured correctly! Missing 'domain'"
12 [ -z "$username" ] && write_log
14 "Service section not configured correctly! Missing 'username'"
13 [ -z "$password" ] && write_log
14 "Service section not configured correctly! Missing 'password'"
15 .
/usr
/share
/libubox
/jshn.sh
17 write_log
0 "one.com ddns script started"
19 local __SUBDOMAIN __MAINDOMAIN __LOGINURL __RECORDID
22 COOKIEJAR
=$
(mktemp
/tmp
/one_com_cookiejar.XXXXXX
) ||
exit 1
24 __SUBDOMAIN
=$
(echo $domain |
sed -e 's/[^\.]*\.[^\.]*$//' -e 's/\.$//' )
25 __MAINDOMAIN
=$
(echo $domain |
sed -e "s/${__SUBDOMAIN}\.//" )
29 # GET LOGIN POST URL FROM FORM
34 "https://www.one.com/admin/" \
35 |
grep 'Login-form login autofill' \
36 |
sed -e 's/.*action="//' -e 's/".*//' -e 's/\&/\&/g' \
46 -H "Content-Type: application/x-www-form-urlencoded" \
48 -d "username=${username}&password=${password}&credentialId=" \
49 |
grep "Invalid username or password." > $DATFILE
51 if [ "$?" == "0" ] ; then
52 write_log
14 "Invalid credentials"
62 "https://www.one.com/admin/select-admin-domain.do?domain=${__MAINDOMAIN}" \
63 |
grep "<meta name=\"one.com:active-domain\" content=\"${__MAINDOMAIN}\"/>" > $DATFILE
65 if [ "$?" != "0" ] ; then
66 write_log
14 "Failed to select domain '${__MAINDOMAIN}'"
77 "https://www.one.com/admin/api/domains/${__MAINDOMAIN}/dns/custom_records"
82 if json_is_a
"result" "object" && \
83 json_select
"result" && \
84 json_is_a
"data" "array"
88 while json_is_a
${i} "object" ; do
90 json_select
"attributes"
91 json_get_var
"prefix" "prefix"
93 if [ "$prefix" == "$__SUBDOMAIN" ] ; then
94 json_get_var
"__RECORDID" "id"
95 write_log
0 "Found record id : ${__RECORDID}"
104 if [ "${__RECORDID}" == "" ] ; then
105 write_log
14 "domain record not found"
110 # CREATING PATCH DATA
112 json_add_string
"type" "dns_service_records"
113 json_add_string
"id" "${__RECORDID}"
114 json_add_object
"attributes"
115 json_add_string
"type" "A"
116 json_add_string
"prefix" "${__SUBDOMAIN}"
117 json_add_string
"content" "${__IP}"
118 json_add_int
"ttl" ${__TTL}
119 patchdata
=$
(json_dump
)
130 -H "Content-Type: application/json" \
131 "https://www.one.com/admin/api/domains/${__MAINDOMAIN}/dns/custom_records/${__RECORDID}" \
132 |
grep "priority" > $DATFILE
134 if [ "$?" != "0" ] ; then
135 write_log
14 "one.com gave an unexpected response"
140 write_log
0 "one.com ddns script finished without errors"