#!/bin/bash

## Copyright (C) 2020 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -x
set -e

if [ ! "$(id -u)" = "0" ]; then
  true "$0: ERROR: Must be run as root!"
  exit 1
fi

systemctl stop tor@default
systemctl stop vanguards &>/dev/null || true

date --set "Sat 09 Jan 2050 02:33:24 AM UTC"

rm -f /var/lib/tor/cached-certs
rm -f /var/lib/tor/cached-microdesc-consensus
rm -f /var/lib/tor/cached-microdescs.new
rm -f /var/lib/tor/keys
rm -f /var/lib/tor/lock
rm -f /var/lib/tor/state
rm -f /var/lib/tor/vanguards.state

if systemctl is-enabled vanguards &>/dev/null ; then
  systemctl restart vanguards || true
fi
systemctl restart tor@default

sdwdate-clock-jump

true "$0: OK"
