qubes.SetDateTime 332 B

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