[packages] ddns-scripts:

add option use_syslog to enable logging to syslog
use wget when it's compiled with ssl support

Signed-off-by: Peter Wagner <tripolar@gmx.at>



git-svn-id: svn://svn.openwrt.org/openwrt/packages@38548 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
tripolar 2013-10-27 22:12:10 +00:00
parent 73aa9d7d82
commit deb4ff1c07
4 changed files with 40 additions and 24 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ddns-scripts
PKG_VERSION:=1.0.0
PKG_RELEASE:=21
PKG_RELEASE:=22
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

View File

@ -65,11 +65,13 @@
config service "myddns"
option enabled "0"
option interface "wan"
option use_syslog "1"
option service_name "dyndns.org"
option domain "mypersonaldomain.dyndns.org"
option username "myusername"
option password "mypassword"
option use_https "0"
option force_interval "72"
option force_unit "hours"

View File

@ -108,6 +108,14 @@ verbose_echo()
fi
}
syslog_echo()
{
if [ "$use_syslog" = 1 ]
then
echo $1|logger -t ddns-scripts-$service_id
fi
}
start_daemon_for_all_ddns_sections()
{
local event_interface="$1"

View File

@ -46,6 +46,7 @@ fi
#
#
#config_get use_https $service_id use_https
#config_get use_syslog $service_id use_syslog
#config_get cacert $service_id cacert
#
#config_get ip_source $service_id ip_source
@ -78,7 +79,6 @@ then
check_unit="seconds"
fi
if [ -z "$force_interval" ]
then
force_interval=72
@ -89,29 +89,45 @@ then
force_unit="hours"
fi
if [ -z $use_syslog ]
then
use_syslog=0
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" ]
/usr/bin/wget --version 2>&1 |grep -q "\+ssl"
if [ $? -eq 0 ]
then
retrieve_prog="${retrieve_prog}--cacert $cacert "
elif [ -d "$cacert" ]
then
retrieve_prog="${retrieve_prog}--capath $cacert "
if [ -f "$cacert" ]
then
retrieve_prog="${retrieve_prog}--ca-certificate=${cacert} "
elif [ -d "$cacert" ]
then
retrieve_prog="${retrieve_prog}--ca-directory=${cacert} "
fi
else
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
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\}"
@ -119,7 +135,6 @@ ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"
NEWLINE_IFS='
'
#determine what update url we're using if the service_name is supplied
if [ -n "$service_name" ]
then
@ -149,21 +164,14 @@ then
update_url=$(echo $update_url | sed -e 's/^http:/https:/')
fi
verbose_echo "update_url=$update_url"
#if this service isn't enabled then quit
if [ "$enabled" != "1" ]
then
return 0
fi
#compute update interval in seconds
case "$force_unit" in
"days" )
@ -185,7 +193,6 @@ case "$force_unit" in
esac
#compute check interval in seconds
case "$check_unit" in
"days" )
@ -207,7 +214,6 @@ case "$check_unit" in
esac
#compute retry interval in seconds
case "$retry_unit" in
"days" )
@ -229,7 +235,6 @@ case "$retry_unit" in
esac
verbose_echo "force seconds = $force_interval_seconds"
verbose_echo "check seconds = $check_interval_seconds"
@ -283,7 +288,7 @@ do
current_time=$(monotonic_time)
time_since_update=$(($current_time - $last_update))
syslog_echo "Running IP check ..."
verbose_echo "Running IP check..."
verbose_echo "current system ip = $current_ip"
verbose_echo "registered domain ip = $registered_ip"
@ -315,11 +320,12 @@ do
update_output=$( $retrieve_prog "$final_url" )
if [ $? -gt 0 ]
then
syslog_echo "update failed, retrying in $retry_interval_seconds seconds"
verbose_echo "update failed"
sleep $retry_interval_seconds
continue
fi
syslog_echo "Update successful"
verbose_echo "Update Output:"
verbose_echo "$update_output"
verbose_echo ""