[heartbeat] use heartbeat return timestamp to sync time in case ntpclient does not get the job done

This commit is contained in:
Bart Van Der Meerssche 2011-04-18 21:55:24 +02:00
parent 53294f1aea
commit 66ee322216
1 changed files with 9 additions and 1 deletions

View File

@ -132,9 +132,17 @@ if call_info.headers['X-Digest'] ~= hash:final() then
os.exit(3) os.exit(3)
end end
-- check whether we have to reset or upgrade
local response = luci.json.decode(response_json) local response = luci.json.decode(response_json)
-- use heartbeat return timestamp to sync time in case ntpclient doesn't get the job done
local TIMESTAMP_MIN = 1234567890
local TIMESTAMP = tonumber(response.timestamp)
if os.time() < TIMESTAMP_MIN then
nixio.settimeofday(TIMESTAMP)
end
-- check whether we have to reset or upgrade
if response.upgrade == monitor.version then if response.upgrade == monitor.version then
os.execute('reboot') os.execute('reboot')
elseif response.upgrade > monitor.version then elseif response.upgrade > monitor.version then