only do a update if DNS entry is outdated

This commit is contained in:
Daniel Steglich 2015-03-06 21:34:57 +01:00
parent 7d44f0c4e4
commit 6acc4cc44f

View File

@ -269,23 +269,26 @@ doGetWANIP()
# this function is called via cronjob
doUpdate()
{
dnsentry=$(nslookup ${host}|tail -n2|grep A|sed s/[^0-9.]//g)
if [ "${dnsentry}" = "${wanip}" ];then
return
fi
if [ ! -z ${server} ];then
start-stop-daemon -S -x ${UPDATE_TOOL} -m -p ${PIDFILE} -- -c ${cfgfile}
fi
if [ ! -z ${updateurl} ];then
doReplaceVars
if [ "${basicauth}" = "enabled" ];then
local wgetoptions=" --user $user --password $pass "
local wgetoptions=" --user ${user} --password ${pass} "
fi
if [ "${ignoreCertError}" = "enabled" ];then
local wgetoptions=" --no-check-certificate "
fi
$WGET ${wgetoptions} "${updateurl}"
${WGET} ${wgetoptions} "${updateurl}"
# ToDo: check the returning text from WEB Server. User need to give expected string.
if [ $? -eq 0 ];then
${0} success $wanip
if [ ${?} -eq 0 ];then
${0} success ${wanip}
else
${0} failed
fi