core-agent-linux/qubes-rpc/qubes.SetDateTime
Marek Marczykowski-Górecki 9c839d789f
qubes-rpc: fix issues found by shellcheck
Most of them are missing quotes, `` -> $(), and -o/-a usage in
conditions. Also add few directives disabling checks where were too
verbose.
2017-09-30 04:45:31 +02:00

12 linhas
356 B
Bash
Arquivo executável

#!/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 -r timestamp
timediff=$(( $(date -u +'+%Y%m%d%H%M%S') - $(date -u -d "$timestamp" +'+%Y%m%d%H%M%S') ))
if [ "$timediff" -le 2 ] && [ "$timediff" -ge -2 ]; then
# don't bother
exit 0
fi
date -u -s "$timestamp" >/dev/null