Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Patrick Schleizer
committed
Mar 18, 2016
1 parent
89de971
commit 95850f6
Showing
3 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
if [ ! "$(id -u)" = "0" ]; then | ||
echo "ERROR: Must run as root!" >&2 | ||
echo "$0 ERROR: Must run as root!" >> /var/log/sdwdate.log | ||
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 | ||
echo "$0 INFO: Clock fix after resume not implemented in Non-Qubes-Whonix. See: https://www.whonix.org/wiki/Troubleshooting#Clock_Fix" >> /var/log/sdwdate.log | ||
exit 3 | ||
fi | ||
|
||
echo "$0 INFO: date before roughly fixing it: $(date -u)" >> /var/log/sdwdate.log | ||
|
||
date --set "@$randomized_unix_time" >/dev/null | ||
|
||
echo "$0 INFO: date after roughly fixing it : $(date -u)" >> /var/log/sdwdate.log | ||
|
||
echo "$0 INFO: Restarting sdwdate..." >> /var/log/sdwdate.log | ||
service sdwdate restart | ||
echo "$0 INFO: Done, restarted sdwdate." >> /var/log/sdwdate.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
if [ ! "$(id -u)" = "0" ]; then | ||
echo "ERROR: Must run as root!" >&2 | ||
echo "$0 ERROR: Must run as root!" >> /var/log/sdwdate.log | ||
exit 2 | ||
fi | ||
|
||
## Do not interfere with the clock if the service was stopped. | ||
if test -f /var/run/sdwdate/was_running.status ; then | ||
echo "$0 INFO: Deleting /var/run/sdwdate/was_running.status..." >> /var/log/sdwdate.log | ||
rm -f /var/run/sdwdate/was_running.status | ||
echo "$0 INFO: Done, deleted /var/run/sdwdate/was_running.status." >> /var/log/sdwdate.log | ||
echo "$0 INFO: Running /usr/lib/sdwdate/clock-fix..." | ||
/usr/lib/sdwdate/clock-fix || true | ||
echo "$0 INFO: Done with /usr/lib/sdwdate/clock-fix." | ||
else | ||
echo "$0 INFO: File /var/run/sdwdate/was_running.status did not exist, meaning we previously did not stop sdwdate so not starting it now." >> /var/log/sdwdate.log | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
if [ ! "$(id -u)" = "0" ]; then | ||
echo "ERROR: Must run as root!" >&2 | ||
echo "$0 ERROR: Must run as root!" >> /var/log/sdwdate.log | ||
exit 2 | ||
fi | ||
|
||
if service sdwdate status >/dev/null ; then | ||
echo "$0 INFO: Creating /var/run/sdwdate/was_running.status..." >> /var/log/sdwdate.log | ||
touch /var/run/sdwdate/was_running.status | ||
echo "$0 INFO: Done, created /var/run/sdwdate/was_running.status." >> /var/log/sdwdate.log | ||
echo "$0 INFO: Stopping sdwdate..." >> /var/log/sdwdate.log | ||
service sdwdate stop | ||
echo "$0 INFO: Done, stopped sdwdate." >> /var/log/sdwdate.log | ||
else | ||
echo "$0 INFO: sdwdate was not running, no need to stop it." >> /var/log/sdwdate.log | ||
fi |