#!/bin/bash

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

#### meta start
#### project Whonix
#### category tor and usability
#### description
#### gateway_only yes
## Stops Tor, deletes Tor consensus using `anon-consensus-del-files` and restarts Tor.
#### meta end

if ! [ "$(id -u)" = 0 ]; then
   echo "$0: ERROR: This script must run as root/sudo! run:"
   echo "sudo $0"
   exit 1
fi

systemctl --no-pager stop tor
systemctl --no-pager stop vanguards &>/dev/null || true

anon-consensus-del-files

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