#!/bin/bash

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

## Keep the command trace so the user sees the apt commands run here.
set -x
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
shopt -s inherit_errexit
shopt -s shift_verbose
export LC_ALL=C

apt-get-noninteractive update

apt-get-noninteractive --no-install-recommends --yes install tb-updater tb-starter

## Apt commants have been run, xtrace would just be confusing now.
set +x

## sets: boot_session
## FIXME: We need helper-scripts pulled in for CI to avoid a shellcheck issue
## here.
# shellcheck source=../../../../helper-scripts/usr/libexec/helper-scripts/boot-session-detection.bsh
source "${HELPER_SCRIPTS_PATH:-}"/usr/libexec/helper-scripts/boot-session-detection.bsh

if [ "${boot_session}" = "sysmaint_session" ]; then
  printf '%s\n' "
------------------------------------------------------------------------------
Done installing tb-updater and tb-starter. Reboot into
\"PERSISTENT Mode | USER Session\", then launch \"Tor Browser (AnonDist)\"
from the application menu to download and run Tor Browser.
------------------------------------------------------------------------------
"
else
  printf '%s\n' "
------------------------------------------------------------------------------
INFO: Done installing tb-updater and tb-starter. Launch \"Tor Browser
(AnonDist)\" from the application menu to download and run Tor Browser.
------------------------------------------------------------------------------
"
fi
