diff --git a/misc/install.sh b/misc/install.sh index 1945e5bd..ef82550a 100755 --- a/misc/install.sh +++ b/misc/install.sh @@ -8,6 +8,7 @@ ENIGMA_INSTALL_DIR=${ENIGMA_INSTALL_DIR:=$HOME/enigma-bbs} ENIGMA_SOURCE=${ENIGMA_SOURCE:=https://github.com/NuSkooler/enigma-bbs.git} TIME_FORMAT=`date "+%Y-%m-%d %H:%M:%S"` WAIT_BEFORE_INSTALL=10 +PYTHON_VERSION="3.10" enigma_header() { clear @@ -31,14 +32,6 @@ Installing ENiGMA½: >> Installation will continue in ${WAIT_BEFORE_INSTALL} seconds... EndOfMessage - - SECS=10 - while [ $SECS -gt 0 ]; do - echo -ne "${SECS}... " - sleep 1 - ((SECS --)) - done - echo "" } fatal_error() { @@ -147,11 +140,35 @@ install_node_packages() { } copy_template_files() { - if [[ ! -f "./gopher/gophermap" ]]; then - cp "./misc/gophermap" "./gopher/gophermap" + echo $ENIGMA_INSTALL_DIR + if [[ ! -f "$ENIGMA_INSTALL_DIR/gopher/gophermap" ]]; then + cp "$ENIGMA_INSTALL_DIR/misc/gophermap" "$ENIGMA_INSTALL_DIR/gopher/gophermap" fi } +install_python_environment() { + log "Installing required Python Runtime Environment..." + log "Note that on some systems such as RPi, this can take a VERY long time. Be patient!" + + cd ${ENIGMA_INSTALL_DIR} + curl -o- https://pyenv.run | bash + export PYENV_ROOT="$HOME/.pyenv" + [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" + + if [ $? -eq 0 ]; then + log "Python 3.10 installation complete" + else + log "NOTE: The following build dependencies must be installed:" + log "bzip2 libncurses-dev libffi-dev libz-dev libssl-dev libbz2-dev libreadline-dev libsqlite3-dev liblzma-dev" + + fatal_error "Failed to install Python 3.10 runtime environment. Please report this!" + fi + + eval "$(pyenv init -)" + pyenv install $PYTHON_VERSION + pyenv local $PYTHON_VERSION +} + enigma_footer() { log "ENiGMA½ installation complete!" echo -e "\e[1;33m" @@ -185,17 +202,73 @@ ADDITIONAL ACTIONS ARE REQUIRED! See docs for more information including other useful binaries! +4 - Start ENiGMA½ BBS! + + ./autoexec.sh + EndOfMessage echo -e "\e[39m" } +countdown() { + SECS=10 + while [ $SECS -gt 0 ]; do + echo -ne "${SECS}... " + sleep 1 + ((SECS --)) + done + echo "" +} + +install_node_runtime_environment() { + enigma_install_init + install_nvm + configure_nvm + install_node_packages +} + +install_bbs() { + download_enigma_source + copy_template_files +} + +install_everything() { + countdown + enigma_install_init + install_nvm + configure_nvm + download_enigma_source + install_node_packages + install_python_environment + copy_template_files +} + +menu() { + title="Installation Options" + prompt="Pick an option:" + options=( + "Install Python $PYTHON_VERSION Runtime Environment" + "Install Node $ENIGMA_NODE_VERSION Runtime Environment" + "Install ENiGMA½" + "Install Everything" + ) + + echo "$title" + PS3="$prompt " + select opt in "${options[@]}" "Quit"; do + case "$REPLY" in + 1) enigma_install_init; install_python_environment; break;; + 2) enigma_install_init; install_node_runtime_environment; break;; + 3) install_bbs; break;; + 4) enigma_install_init; install_everything; break;; + $((${#options[@]}+1))) echo "Goodbye!"; break;; + *) echo "Invalid option. Try another one.";continue;; + esac + done +} + enigma_header -enigma_install_init -install_nvm -configure_nvm -download_enigma_source -install_node_packages -copy_template_files +menu enigma_footer } # this ensures the entire script is downloaded before execution