Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Script Enhancement and Startup Script #580

Merged
merged 29 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions autoexec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
crhultay marked this conversation as resolved.
Show resolved Hide resolved

# Setup Node Environment
export NVM_DIR="$HOME/.nvm"
crhultay marked this conversation as resolved.
Show resolved Hide resolved
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm use 18

# Setup Python Environment
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
pyenv local 3.10

# Start BBS
/home/egonis/enigma-bbs/main.js
result=$?

# Determine whether a Startup Crash Occurred
if [ $result -eq 0 ]; then
echo "$result"
else
echo "FAIL: ENiGMA½ exited with $result"

# TODO: Notify via SMS / Email of Startup Failure
fi
104 changes: 88 additions & 16 deletions misc/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -147,9 +140,32 @@ install_node_packages() {
}

copy_template_files() {
if [[ ! -f "./gopher/gophermap" ]]; then
cp "./misc/gophermap" "./gopher/gophermap"
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() {
Expand Down Expand Up @@ -185,17 +201,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
Loading