core-agent-linux/qubes-rpc/qubes.SetDateTime
Marek Marczykowski-Górecki 0e062ff31e
Fix time sync service
It is expected to not output anything on stdout. Especially remote end
may be already terminated, so writing there would result in EPIPE.

Fixes QubesOS/qubes-issues#1592
2016-01-07 05:06:39 +01:00

12 lines
343 B
Bash

#!/bin/sh
# it is in format of `date -u -Iseconds`, example: 2014-09-29T22:59:21+0000
# it comes from dom0, so is trusted
read timestamp
timediff=$(( `date -u +'+%Y%m%d%H%M%S'` - `date -u -d "$timestamp" +'+%Y%m%d%H%M%S'` ))
if [ $timediff -le 2 -a $timediff -ge -2 ]; then
# don't bother
exit 0
fi
date -u -s "$timestamp" >/dev/null