#!/bin/bash

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

set -x
set -e
set -o errexit
set -o nounset
set -o errtrace
set -o pipefail

true "$0: START"

state_arg="${1:-}"
if [ -z "${state_arg}" ]; then
   echo "$0: Missing argument."
   exit 1
fi

case "${state_arg}" in
   'reload')
      /usr/bin/systemctl --no-pager reload tor@default
      ;;
   'restart')
      /usr/bin/systemctl --no-pager restart tor@default
      ;;
   'stop')
      /usr/bin/systemctl --no-pager stop tor@default
      ;;
   'status')
      /usr/bin/systemctl --no-pager status tor@default
      ;;
   *)
     echo "$0: Invalid argument."
     exit 1
     ;;
esac

true "$0: END"
