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