43d043a9cd
* initial commit - add prereqs install script * add env vars prompt * automate latest binary url env var * add install node script * add modes to nym-node install script * start main cli framework * adding branch var for easier deployment and testing * add systemd config * add proxy and wss setup script * add landing page stub and fix nginx script * add nginx setup * fix typo * add checks for existing dir and wg prompt * add nginx commands * add service file check * add service file check * convention alignment * add checks to nginx setup * cleanup old code * add bonding prompt and nym node run fns * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * add service script to init * fix syntax * fix syntax * add chmod * fix script logic * syntax fix * syntax fix * silent mode trial * fix evn prompt script * make scripts interactive * indent fix * correct node-install script * initial mixnode setup working - gws need more love * fix bonding function * syntax fix * improve run noide as service script * improve service script * improve run service fn * fix logic * beautify * beautify * create run node as service script * syntax fix * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * setting wireguard * solved memory issues * rename landing page template * modify wireguard enabled fn * layout change * syntax fix * modify node setup script * sync up envs * return missing function * fix urls * fix network manager script execution * fix wss and nginx * fix layout * tweak WG contion * syntax fix * add init placeholder * syntax fix * redefine wireguard check logic * check if node exists * add argparse and dev option * styling * add panic * add error message * improve logic * improve logic * add arg * add dev arg for all levels * add confirmation loop * styling * fix bonding question * syntax edit * syntax edit * syntax edit * refactor for already bonded nodes * add default branch on top and define metavar * fix node install script * clean and prepare for review * indentation fix * fix nginx setup * fix nginx setup * style cleanup * fix try error logic * tune --dev option to run before command correctly * fix y/n convention across the modules * add explorer URL to the message * minor layout fixes
76 lines
2.3 KiB
Bash
76 lines
2.3 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
|
|
|
|
# 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"
|
|
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
|
|
|
|
# try to get the latest binary URL (non-fatal if missing)
|
|
LATEST_BINARY=$(
|
|
curl -fsSL https://github.com/nymtech/nym/releases/latest \
|
|
| grep -Eo 'href="/nymtech/nym/releases/download/[^"]+/nym-node"' \
|
|
| head -n1 \
|
|
| cut -d'"' -f2
|
|
)
|
|
if [[ -z "${LATEST_BINARY:-}" ]]; then
|
|
echo "WARNING: Could not determine latest nym-node binary URL right now. The installer will resolve it later."
|
|
fi
|
|
|
|
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}\""
|
|
} > 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
|