From aa5efd498489bc966282ae99a19f3a5ca39891f0 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 1 Feb 2016 10:57:33 +0530 Subject: [PATCH] dynamicdns: Fix computing update times Currenly uptime is being taken as measure to decide whether update must run. Uptime is the number of seconds since machine has booted. If a machine has run for 30 hours, and rebooted, then update will not be done until the machine has run for 30 hours + desinated time. Using seconds since epoch fixes this. --- actions/dynamicdns | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/dynamicdns b/actions/dynamicdns index 4b45a8c37..3968d744f 100755 --- a/actions/dynamicdns +++ b/actions/dynamicdns @@ -374,10 +374,10 @@ case ${cmd} in fi # if we don't know our WAN IP do a blind update once a hour if [ "${wanip}" = ${NOIP} ];then - uptime=$(cut -d . -f 1 /proc/uptime) + currenttime=$(date +%s) LAST=0 [ -f ${LASTUPDATE} ] && LAST=$(cat ${LASTUPDATE}) - diff=$((uptime - LAST)) + diff=$((currenttime - LAST)) if [ ${diff} -gt ${UPDATEMINUTESUNKNOWN} ];then doUpdate fi @@ -392,7 +392,7 @@ case ${cmd} in success) date=$(date) echo "last update done (${date})" > ${STATUSFILE} - awk '{print $1}' /proc/uptime |cut -d . -f 1 > ${LASTUPDATE} + date +%s > ${LASTUPDATE} # if called from cronjob, the current IP is given as parameter if [ $# -eq 1 ];then echo "${1}" > ${IPFILE}