#!/bin/bash

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

set -x
set -e

true "INFO: Currently running script: $BASH_SOURCE $@"

MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd "$MYDIR"
cd ..
cd help-steps

source pre
source colors
source variables

msg_graphical_gateway_low_ram="\
########################
## GATEWAY - LOW RAM? ##
########################

If your computer has 2GB or less RAM, set the RAM for Whonix-Gateway to 256MB to automatically boot into a command-line environment. The Gateway will work normally, and you can configure it via the command-line. If you need a graphical environment, temporarily increase RAM to 512MB to boot to a desktop."

msg_kicksecure_security_advice="\
#####################
## SECURITY ADVICE ##
#####################

Kicksecure with its default settings may provide better protection. You can make it even more secure. It is recommended to read our documentation:
https://www.kicksecure.com/wiki/Documentation"

msg_whonix_security_advice="\
#####################
## SECURITY ADVICE ##
#####################

Whonix with its default settings may provide better protection than Tor alone. You can make it even more secure. It is recommended to read our documentation:
https://www.whonix.org/wiki/Documentation"

msg_kicksecure_disclaimer="\
################
## DISCLAIMER ##
################

The more you learn about Kicksecure, security, and threats to your security, the safer you can become.

Kicksecure is a derivative of and not affiliated with Debian. Debian is a registered trademark owned by Software in the Public Interest, Inc.

Kicksecure is a research project."

msg_whonix_disclaimer="\
################
## DISCLAIMER ##
################

There is no magic pill for anonymity. The more you learn about Whonix, Tor, and threats to your privacy, the safer you can become.

Whonix is produced independently from the Tor (R) anonymity software and carries no guarantee from The Tor Project about quality, suitability or anything else.

Whonix is a derivative of and not affiliated with Debian. Debian is a registered trademark owned by Software in the Public Interest, Inc.

Whonix is a research project."

msg_whonix_workstation_requires_whonix_gateway="\
# For internet access, Whonix-Workstation requires that Whonix-Gateway be running. #"

msg_whonix_workstation_low_ram="\
##########################
## WORKSTATION LOW RAM? ##
##########################

If your computer has less than 2GB RAM, you can lower the RAM for Whonix-Workstation to 512MB. Performance will suffer, but an advanced user can install a lighter desktop environment. Setting RAM to less than 512MB will boot to a command-line environment."

create-vm-text() {
   if [ "$dist_build_flavor" = "whonix-gateway-cli" ]; then
      local TEXT="\
$msg_whonix_security_advice

$msg_whonix_disclaimer"
   elif [ "$dist_build_flavor" = "whonix-workstation-cli" ]; then
      local TEXT="\
$msg_whonix_workstation_requires_whonix_gateway

$msg_whonix_security_advice

$msg_whonix_disclaimer"
   elif [ "$dist_build_type_long" = "gateway" ]; then
      local TEXT="\
$msg_graphical_gateway_low_ram

$msg_whonix_security_advice

$msg_whonix_disclaimer"
   elif [ "$dist_build_type_long" = "workstation" ]; then
      local TEXT="\
$msg_whonix_workstation_requires_whonix_gateway

$msg_whonix_workstation_low_ram

$msg_whonix_security_advice

$msg_whonix_disclaimer"
   elif [ "$dist_build_type_long" = "custom-workstation" ]; then
      local TEXT="\
$msg_whonix_workstation_requires_whonix_gateway

$msg_whonix_security_advice

$msg_whonix_disclaimer"
   elif [ "$dist_build_type_long" = "whonix-host" ]; then
      local TEXT="TODO"
   elif [ "$dist_build_type_long" = "kicksecure" ]; then
      local TEXT="\
$msg_kicksecure_security_advice

$msg_kicksecure_disclaimer"
   else
      local MSG="${bold}${red}$BASH_SOURCE ERROR: dist_build_type_long is neither Kicksecure, nor Whonix-Gateway nor Whonix-Workstation. Please report this bug! ${reset}"
      error "$MSG"
   fi

   echo "$TEXT" | tee "$binary_image_text" >/dev/null
}

main() {
   if [ "$dist_build_virtualbox" = "true" ]; then
      create-vm-text
   else
      true "${green}INFO: Skipping $BASH_SOURCE, because dist_build_virtualbox is not set to 'true'.${reset}"
   fi
}

true "${bold}${under}INFO: Currently running script: $0 "$@"${reset}"
main "$@"
