[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:
parent
73aa9d7d82
commit
deb4ff1c07
@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=ddns-scripts
|
PKG_NAME:=ddns-scripts
|
||||||
PKG_VERSION:=1.0.0
|
PKG_VERSION:=1.0.0
|
||||||
PKG_RELEASE:=21
|
PKG_RELEASE:=22
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
@ -65,11 +65,13 @@
|
|||||||
config service "myddns"
|
config service "myddns"
|
||||||
option enabled "0"
|
option enabled "0"
|
||||||
option interface "wan"
|
option interface "wan"
|
||||||
|
option use_syslog "1"
|
||||||
|
|
||||||
option service_name "dyndns.org"
|
option service_name "dyndns.org"
|
||||||
option domain "mypersonaldomain.dyndns.org"
|
option domain "mypersonaldomain.dyndns.org"
|
||||||
option username "myusername"
|
option username "myusername"
|
||||||
option password "mypassword"
|
option password "mypassword"
|
||||||
|
option use_https "0"
|
||||||
|
|
||||||
option force_interval "72"
|
option force_interval "72"
|
||||||
option force_unit "hours"
|
option force_unit "hours"
|
||||||
|
@ -108,6 +108,14 @@ verbose_echo()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syslog_echo()
|
||||||
|
{
|
||||||
|
if [ "$use_syslog" = 1 ]
|
||||||
|
then
|
||||||
|
echo $1|logger -t ddns-scripts-$service_id
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
start_daemon_for_all_ddns_sections()
|
start_daemon_for_all_ddns_sections()
|
||||||
{
|
{
|
||||||
local event_interface="$1"
|
local event_interface="$1"
|
||||||
|
@ -46,6 +46,7 @@ fi
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#config_get use_https $service_id use_https
|
#config_get use_https $service_id use_https
|
||||||
|
#config_get use_syslog $service_id use_syslog
|
||||||
#config_get cacert $service_id cacert
|
#config_get cacert $service_id cacert
|
||||||
#
|
#
|
||||||
#config_get ip_source $service_id ip_source
|
#config_get ip_source $service_id ip_source
|
||||||
@ -78,7 +79,6 @@ then
|
|||||||
check_unit="seconds"
|
check_unit="seconds"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$force_interval" ]
|
if [ -z "$force_interval" ]
|
||||||
then
|
then
|
||||||
force_interval=72
|
force_interval=72
|
||||||
@ -89,29 +89,45 @@ then
|
|||||||
force_unit="hours"
|
force_unit="hours"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z $use_syslog ]
|
||||||
|
then
|
||||||
|
use_syslog=0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$use_https" ]
|
if [ -z "$use_https" ]
|
||||||
then
|
then
|
||||||
use_https=0
|
use_https=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#some constants
|
#some constants
|
||||||
|
|
||||||
|
retrieve_prog="/usr/bin/wget -O - ";
|
||||||
if [ "x$use_https" = "x1" ]
|
if [ "x$use_https" = "x1" ]
|
||||||
then
|
then
|
||||||
retrieve_prog="/usr/bin/curl "
|
/usr/bin/wget --version 2>&1 |grep -q "\+ssl"
|
||||||
if [ -f "$cacert" ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
retrieve_prog="${retrieve_prog}--cacert $cacert "
|
if [ -f "$cacert" ]
|
||||||
elif [ -d "$cacert" ]
|
then
|
||||||
then
|
retrieve_prog="${retrieve_prog}--ca-certificate=${cacert} "
|
||||||
retrieve_prog="${retrieve_prog}--capath $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
|
fi
|
||||||
else
|
|
||||||
retrieve_prog="/usr/bin/wget -O - ";
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
service_file="/usr/lib/ddns/services"
|
service_file="/usr/lib/ddns/services"
|
||||||
|
|
||||||
ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"
|
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='
|
NEWLINE_IFS='
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
||||||
#determine what update url we're using if the service_name is supplied
|
#determine what update url we're using if the service_name is supplied
|
||||||
if [ -n "$service_name" ]
|
if [ -n "$service_name" ]
|
||||||
then
|
then
|
||||||
@ -149,21 +164,14 @@ then
|
|||||||
update_url=$(echo $update_url | sed -e 's/^http:/https:/')
|
update_url=$(echo $update_url | sed -e 's/^http:/https:/')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
verbose_echo "update_url=$update_url"
|
verbose_echo "update_url=$update_url"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if this service isn't enabled then quit
|
#if this service isn't enabled then quit
|
||||||
if [ "$enabled" != "1" ]
|
if [ "$enabled" != "1" ]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#compute update interval in seconds
|
#compute update interval in seconds
|
||||||
case "$force_unit" in
|
case "$force_unit" in
|
||||||
"days" )
|
"days" )
|
||||||
@ -185,7 +193,6 @@ case "$force_unit" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#compute check interval in seconds
|
#compute check interval in seconds
|
||||||
case "$check_unit" in
|
case "$check_unit" in
|
||||||
"days" )
|
"days" )
|
||||||
@ -207,7 +214,6 @@ case "$check_unit" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#compute retry interval in seconds
|
#compute retry interval in seconds
|
||||||
case "$retry_unit" in
|
case "$retry_unit" in
|
||||||
"days" )
|
"days" )
|
||||||
@ -229,7 +235,6 @@ case "$retry_unit" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
verbose_echo "force seconds = $force_interval_seconds"
|
verbose_echo "force seconds = $force_interval_seconds"
|
||||||
verbose_echo "check seconds = $check_interval_seconds"
|
verbose_echo "check seconds = $check_interval_seconds"
|
||||||
|
|
||||||
@ -283,7 +288,7 @@ do
|
|||||||
current_time=$(monotonic_time)
|
current_time=$(monotonic_time)
|
||||||
time_since_update=$(($current_time - $last_update))
|
time_since_update=$(($current_time - $last_update))
|
||||||
|
|
||||||
|
syslog_echo "Running IP check ..."
|
||||||
verbose_echo "Running IP check..."
|
verbose_echo "Running IP check..."
|
||||||
verbose_echo "current system ip = $current_ip"
|
verbose_echo "current system ip = $current_ip"
|
||||||
verbose_echo "registered domain ip = $registered_ip"
|
verbose_echo "registered domain ip = $registered_ip"
|
||||||
@ -315,11 +320,12 @@ do
|
|||||||
update_output=$( $retrieve_prog "$final_url" )
|
update_output=$( $retrieve_prog "$final_url" )
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
then
|
then
|
||||||
|
syslog_echo "update failed, retrying in $retry_interval_seconds seconds"
|
||||||
verbose_echo "update failed"
|
verbose_echo "update failed"
|
||||||
sleep $retry_interval_seconds
|
sleep $retry_interval_seconds
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
syslog_echo "Update successful"
|
||||||
verbose_echo "Update Output:"
|
verbose_echo "Update Output:"
|
||||||
verbose_echo "$update_output"
|
verbose_echo "$update_output"
|
||||||
verbose_echo ""
|
verbose_echo ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user