mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
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.
This commit is contained in:
parent
2a030f91fe
commit
aa5efd4984
@ -374,10 +374,10 @@ case ${cmd} in
|
|||||||
fi
|
fi
|
||||||
# if we don't know our WAN IP do a blind update once a hour
|
# if we don't know our WAN IP do a blind update once a hour
|
||||||
if [ "${wanip}" = ${NOIP} ];then
|
if [ "${wanip}" = ${NOIP} ];then
|
||||||
uptime=$(cut -d . -f 1 /proc/uptime)
|
currenttime=$(date +%s)
|
||||||
LAST=0
|
LAST=0
|
||||||
[ -f ${LASTUPDATE} ] && LAST=$(cat ${LASTUPDATE})
|
[ -f ${LASTUPDATE} ] && LAST=$(cat ${LASTUPDATE})
|
||||||
diff=$((uptime - LAST))
|
diff=$((currenttime - LAST))
|
||||||
if [ ${diff} -gt ${UPDATEMINUTESUNKNOWN} ];then
|
if [ ${diff} -gt ${UPDATEMINUTESUNKNOWN} ];then
|
||||||
doUpdate
|
doUpdate
|
||||||
fi
|
fi
|
||||||
@ -392,7 +392,7 @@ case ${cmd} in
|
|||||||
success)
|
success)
|
||||||
date=$(date)
|
date=$(date)
|
||||||
echo "last update done (${date})" > ${STATUSFILE}
|
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 called from cronjob, the current IP is given as parameter
|
||||||
if [ $# -eq 1 ];then
|
if [ $# -eq 1 ];then
|
||||||
echo "${1}" > ${IPFILE}
|
echo "${1}" > ${IPFILE}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user