#!/bin/bash

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

#### meta start
#### project Whonix
#### category firewall and usability
#### description
## wrapper to restart firewall
#### meta end

set -x
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
shopt -s inherit_errexit
shopt -s shift_verbose

cat -- /etc/motd

if sudo -- /usr/bin/whonix_firewall; then
  firewall_status=0
else
  firewall_status="$?"
fi

if (( firewall_status == 0 )); then
  printf '%s\n' "OK: Whonix firewall reload completed successfully."
else
  printf '%s\n' "ERROR: Whonix firewall reload failed with exit code '${firewall_status}'!" >&2
fi

true "Feel free to close this window."

sleep 86400

exit "${firewall_status}"
