Files
p17o 84a4924e77 nym-node-setup: plumb HOST_SSH_PORT through tunnel manager, CLI, and env setup (#6633)
* network-tunnel-manager: make SSH port configurable

* Rename SSH_PORT to HOST_SSH_PORT.

* setup: plumb HOST_SSH_PORT through env and CLI

* setup-env-vars: persist HOST_SSH_PORT in env.sh

---------

Co-authored-by: p17o <p17o>
2026-04-30 07:10:21 +00:00

70 lines
2.2 KiB
Bash

#!/usr/bin/env bash
# setup_env.sh
# set -euo pipefail
echo -e "\n* * * Setting up environmental variables to ./env.sh * * *"
# detect if we're being sourced
if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then
__SOURCED=1
else
__SOURCED=0
fi
while true; do
# prompt user
read -rp "Enter hostname (if you don't use a DNS, press enter): " HOSTNAME
read -rp "Enter node location (country code or name): " LOCATION
read -rp "Enter your email: " EMAIL
read -rp "Enter node public moniker (visible in the explorer and NymVPN app): " MONIKER
read -rp "Enter node public description: " DESCRIPTION
read -rp "Enter host SSH port (press enter for default port 22): " HOST_SSH_PORT
HOST_SSH_PORT="${HOST_SSH_PORT:-22}"
# show summary table
echo -e "\nPlease confirm the values you entered:"
echo "---------------------------------------"
printf "%-20s %s\n" "HOSTNAME:" "$HOSTNAME"
printf "%-20s %s\n" "LOCATION:" "$LOCATION"
printf "%-20s %s\n" "EMAIL:" "$EMAIL"
printf "%-20s %s\n" "MONIKER:" "$MONIKER"
printf "%-20s %s\n" "DESCRIPTION:" "$DESCRIPTION"
printf "%-20s %s\n" "HOST_SSH_PORT:" "$HOST_SSH_PORT"
echo "---------------------------------------"
read -rp "Are these correct? (y/n): " CONFIRM
case "$CONFIRM" in
[Yy]* ) break ;; # confirmed, exit loop
[Nn]* ) echo -e "\nLet's try again...\n" ;; # loop restarts
* ) echo "Please answer y or n." ;;
esac
done
PUBLIC_IP=$(curl -fsS -4 https://ifconfig.me || true)
PUBLIC_IP=${PUBLIC_IP:-""}
# write env.sh
{
[[ -n "${LATEST_BINARY:-}" ]] && echo "export LATEST_BINARY=\"https://github.com${LATEST_BINARY}\""
echo "export HOSTNAME=\"${HOSTNAME}\""
echo "export LOCATION=\"${LOCATION}\""
echo "export EMAIL=\"${EMAIL}\""
echo "export MONIKER=\"${MONIKER}\""
echo "export DESCRIPTION=\"${DESCRIPTION}\""
echo "export PUBLIC_IP=\"${PUBLIC_IP}\""
echo "export HOST_SSH_PORT=\"${HOST_SSH_PORT}\""
} > env.sh
echo -e "\nVariables saved to ./env.sh"
if [[ $__SOURCED -eq 1 ]]; then
# shellcheck disable=SC1091
. ./env.sh
echo "Loaded into current shell (because you sourced this script)."
else
echo "To load them into your current shell, run: source ./env.sh"
fi