[package] ddns-scripts: add https support to ddns-scripts
authorFlorian Fainelli <florian@openwrt.org>
Sat, 19 Feb 2011 12:44:03 +0000 (12:44 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Sat, 19 Feb 2011 12:44:03 +0000 (12:44 +0000)
adds a "use_https" and "cacert" option to the ddns-scripts package.

when use_https is enabled, then curl is required to perform the update.

the cacert option can be set to either a single file containing a trust
signing authority certificate or a directory containing certificates
which has been prepared with the usual c_rehash method.

Signed-off-by: Matthew William Cox <matt@mattcox.ca>
SVN-Revision: 25578

net/ddns-scripts/Makefile
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh

index 5b42a816e8a9a28882646be69c72c33dea7d328b..680e8940aedd962a620b6f25b6a546f4466efbb9 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ddns-scripts
 PKG_VERSION:=1.0.0
-PKG_RELEASE:=12
+PKG_RELEASE:=13
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
index a58b30729434cb25818d599f7eab02d3858292e0..e8e08e72062612d6dc7c3ca7a9958bb87656a438 100755 (executable)
@@ -45,6 +45,9 @@ fi
 #config_get domain $service_id domain
 #
 #
+#config_get use_https $service_id use_https
+#config_get cacert $service_id cacert
+#
 #config_get ip_source $service_id ip_source
 #config_get ip_interface $service_id ip_interface
 #config_get ip_network $service_id ip_network
@@ -81,11 +84,29 @@ then
        force_unit="hours"
 fi
 
+if [ -z "$use_https" ]
+then
+       use_https=0
+fi
+
 
 
 #some constants
 
-retrieve_prog="/usr/bin/wget -O - ";
+if [ "x$use_https" = "x1" ]
+then
+       retrieve_prog="/usr/bin/curl "
+       if [ -f "$cacert" ]
+       then
+               retrieve_prog="${retrieve_prog}--cacert $cacert "
+       elif [ -d "$cacert" ]
+       then
+               retrieve_prog="${retrieve_prog}--capath $cacert "
+       fi
+else
+       retrieve_prog="/usr/bin/wget -O - ";
+fi
+
 service_file="/usr/lib/ddns/services"
 
 ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"
@@ -118,6 +139,10 @@ then
        IFS=$OLD_IFS
 fi
 
+if [ "x$use_https" = x1 ]
+then
+       update_url=$(echo $update_url | sed -e 's/^http:/https:/')
+fi
 
 
 verbose_echo "update_url=$update_url"