PKG_NAME:=ddns-scripts
PKG_VERSION:=2.8.2
-PKG_RELEASE:=21
+PKG_RELEASE:=22
PKG_LICENSE:=GPL-2.0
"option param_opt" to contain the TTL of the DNS record to update
endef
+define Package/ddns-scripts-one
+ $(call Package/ddns-scripts/Default)
+ TITLE:=Extension for one.com Control Panel
+ DEPENDS:=ddns-scripts +curl
+endef
+
+define Package/ddns-scrtips-one/description
+ Dynamic DNS Client scripts extension for "one.com".
+ It requires:
+ "option username" to be a valid Email for one.com Control Panel
+ "option password" to be the matching one.com Control Panel password
+ "option domain" to contain the domain / subdomain
+endef
+
define Build/Configure
endef
rm $(1)/usr/share/ddns/default/pdns.json
rm $(1)/usr/share/ddns/default/transip.nl.json
rm $(1)/usr/share/ddns/default/ns1.com.json
+ rm $(1)/usr/share/ddns/default/one.com.json
endef
endef
+define Package/ddns-scripts-one/install
+ $(INSTALL_DIR) $(1)/usr/lib/ddns
+ $(INSTALL_BIN) ./files/usr/lib/ddns/update_one_com.sh \
+ $(1)/usr/lib/ddns
+
+ $(INSTALL_DIR) $(1)/usr/share/ddns/default
+ $(INSTALL_DATA) ./files/usr/share/ddns/default/one.com.json \
+ $(1)/usr/share/ddns/default
+endef
+
+define Package/ddns-scripts-one/prerm
+#!/bin/sh
+if [-z "${IPKG_INSTROOT}" ]; then
+ /etc/init.d/ddns stop
+fi
+exit 0
+endef
+
+
$(eval $(call BuildPackage,ddns-scripts))
$(eval $(call BuildPackage,ddns-scripts-services))
$(eval $(call BuildPackage,ddns-scripts-cloudflare))
$(eval $(call BuildPackage,ddns-scripts-pdns))
$(eval $(call BuildPackage,ddns-scripts-transip))
$(eval $(call BuildPackage,ddns-scripts-ns1))
+$(eval $(call BuildPackage,ddns-scripts-one))
--- /dev/null
+#!/bin/sh
+
+# ONE.COM DDNS SCRIPT
+# REQUIRES CURL
+# $ opkg install curl
+
+# SCRIPT BY LUGICO
+# CONTACT: main@lugico.de
+
+[ -z "$CURL" ] && [ -z "$CURL_SSL" ] && write_log 14 "one.com communication require cURL with SSL support. Please install"
+[ -z "$domain" ] && write_log 14 "Service section not configured correctly! Missing 'domain'"
+[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
+[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
+
+. /usr/share/libubox/jshn.sh
+
+write_log 0 "one.com ddns script started"
+
+local __SUBDOMAIN __MAINDOMAIN __LOGINURL __RECORDID
+local __TTL=3600
+
+COOKIEJAR=$(mktemp /tmp/one_com_cookiejar.XXXXXX) || exit 1
+
+__SUBDOMAIN=$(echo $domain | sed -e 's/[^\.]*\.[^\.]*$//' -e 's/\.$//' )
+__MAINDOMAIN=$(echo $domain | sed -e "s/${__SUBDOMAIN}\.//" )
+
+
+# LOGGING IN
+# GET LOGIN POST URL FROM FORM
+__LOGINURL=$( $CURL \
+ -RsSL \
+ --stderr $ERRFILE \
+ -c $COOKIEJAR \
+ "https://www.one.com/admin/" \
+ | grep 'Login-form login autofill' \
+ | sed -e 's/.*action="//' -e 's/".*//' -e 's/\&/\&/g' \
+)
+
+# POST LOGIN DATA
+$CURL \
+ -RsSL \
+ --stderr $ERRFILE \
+ -c $COOKIEJAR \
+ -b $COOKIEJAR \
+ "${__LOGINURL}" \
+ -H "Content-Type: application/x-www-form-urlencoded" \
+ -X POST \
+ -d "username=${username}&password=${password}&credentialId=" \
+ | grep "Invalid username or password." > $DATFILE
+
+if [ "$?" == "0" ] ; then
+ write_log 14 "Invalid credentials"
+ return 1
+fi
+
+
+# SETTING DOMAIN
+$CURL -RsSL \
+ --stderr $ERRFILE \
+ -c $COOKIEJAR \
+ -b $COOKIEJAR \
+ "https://www.one.com/admin/select-admin-domain.do?domain=${__MAINDOMAIN}" \
+ | grep "<meta name=\"one.com:active-domain\" content=\"${__MAINDOMAIN}\"/>" > $DATFILE
+
+if [ "$?" != "0" ] ; then
+ write_log 14 "Failed to select domain '${__MAINDOMAIN}'"
+ return 1
+fi
+
+
+# GETTING RECORD ID
+records=$( $CURL \
+ -RsSL \
+ --stderr $ERRFILE \
+ -c $COOKIEJAR \
+ -b $COOKIEJAR \
+ "https://www.one.com/admin/api/domains/${__MAINDOMAIN}/dns/custom_records"
+)
+
+json_load "$records"
+
+if json_is_a "result" "object" && \
+ json_select "result" && \
+ json_is_a "data" "array"
+then
+ json_select "data"
+ i=1
+ while json_is_a ${i} "object" ; do
+ json_select "${i}"
+ json_select "attributes"
+ json_get_var "prefix" "prefix"
+ json_close_object
+ if [ "$prefix" == "$__SUBDOMAIN" ] ; then
+ json_get_var "__RECORDID" "id"
+ write_log 0 "Found record id : ${__RECORDID}"
+ break
+ fi
+ json_close_object
+ i=$(($i + 1))
+ done
+fi
+
+
+if [ "${__RECORDID}" == "" ] ; then
+ write_log 14 "domain record not found"
+ return 1
+fi
+
+
+# CREATING PATCH DATA
+json_init
+json_add_string "type" "dns_service_records"
+json_add_string "id" "${__RECORDID}"
+json_add_object "attributes"
+json_add_string "type" "A"
+json_add_string "prefix" "${__SUBDOMAIN}"
+json_add_string "content" "${__IP}"
+json_add_int "ttl" ${__TTL}
+patchdata=$(json_dump)
+
+
+# SENDING PATCH
+$CURL \
+ -RsSL \
+ --stderr $ERRFILE \
+ -c $COOKIEJAR \
+ -b $COOKIEJAR \
+ -X PATCH \
+ -d "$patchdata" \
+ -H "Content-Type: application/json" \
+ "https://www.one.com/admin/api/domains/${__MAINDOMAIN}/dns/custom_records/${__RECORDID}" \
+ | grep "priority" > $DATFILE
+
+if [ "$?" != "0" ] ; then
+ write_log 14 "one.com gave an unexpected response"
+ return 1
+fi
+
+rm $COOKIEJAR
+write_log 0 "one.com ddns script finished without errors"
+
+return 0