Skip to content

Commit

Permalink
added suspend-pre, suspend-post and clock-fix handler scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Schleizer committed Mar 15, 2016
1 parent 0e3de19 commit 5dda984
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
19 changes: 19 additions & 0 deletions usr/lib/sdwdate/clock-fix
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

if [ ! "$(id -u)" = "0" ]; then
echo "ERROR: Must run as root!" >&2
exit 2
fi

if [ -d "/usr/lib/qubes" ]; then
randomized_unix_time="$(timeout --kill-after="5" "5" /usr/lib/qubes/qrexec-client-vm dom0 qubes.GetRandomizedTime)"
else
echo "ERROR: Not implemented in Non-Qubes-Whonix. See: https://www.whonix.org/wiki/Troubleshooting#Clock_Fix" >&2
exit 3
fi

date --set "@$randomized_unix_time" >/dev/null

service sdwdate restart
14 changes: 14 additions & 0 deletions usr/lib/sdwdate/suspend-post
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

if [ ! "$(id -u)" = "0" ]; then
echo "ERROR: Must run as root!" >&2
exit 2
fi

## Do not interfere with the clock if the service was stopped.
if test -f /var/run/sdwdate/was_running.status ; then
rm -f /var/run/sdwdate/was_running.status
/usr/lib/sdwdate/clock-fix || true
fi
13 changes: 13 additions & 0 deletions usr/lib/sdwdate/suspend-pre
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

if [ ! "$(id -u)" = "0" ]; then
echo "ERROR: Must run as root!" >&2
exit 2
fi

if service sdwdate status >/dev/null ; then
touch /var/run/sdwdate/was_running.status
service sdwdate stop
fi

0 comments on commit 5dda984

Please sign in to comment.