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 8 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
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Don't check in SSH keys!
*.pem

# Various directories
# Exclude User-Customized Directories
config/
db/
drop/
Expand All @@ -11,5 +11,13 @@ mail/
node_modules/
docs/_site/
docs/.sass-cache/

docs/.jekyll-cache/

# Ignore Web Assets not included with enigma-bbs
www/*
www/assets/*
!www/otp_register_template.html
!www/reset_password.template.html

# Runtime Environment
.venv
16 changes: 16 additions & 0 deletions autoexec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
crhultay marked this conversation as resolved.
Show resolved Hide resolved

# Activate Mise
eval "$(~/.local/bin/mise activate bash)"

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

# Determine whether a Startup Crash Occurred
# if [ $result -eq 0 ]; then
# # TODO: Notify via SMS / Email of Startup Failure
# fi

echo "ENiGMA½ exited with $result"
exit $result
98 changes: 73 additions & 25 deletions misc/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{ # this ensures the entire script is downloaded before execution

ENIGMA_NODE_VERSION=${ENIGMA_NODE_VERSION:=18}
ENIGMA_PYTHON_VERSION="3.10"
ENIGMA_BRANCH=${ENIGMA_BRANCH:=master}
ENIGMA_INSTALL_DIR=${ENIGMA_INSTALL_DIR:=$HOME/enigma-bbs}
ENIGMA_SOURCE=${ENIGMA_SOURCE:=https://github.com/NuSkooler/enigma-bbs.git}
Expand All @@ -25,20 +26,13 @@ _____________________ _____ ____________________ __________\\_ /
Installing ENiGMA½:
Source : ${ENIGMA_SOURCE} (${ENIGMA_BRANCH} branch)
Destination: ${ENIGMA_INSTALL_DIR}
Node.js : ${ENIGMA_NODE_VERSION}.x via NVM (If you have NVM it will be updated to the latest version)
Node.js : ${ENIGMA_NODE_VERSION} via mise-en-place
Python : ${ENIGMA_PYTHON_VERSION} via mise-en-place

>> If this isn't what you were expecting, hit CTRL-C now!
>> 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 @@ -74,6 +68,16 @@ enigma_install_needs() {
enigma_install_needs_ex $1 "Examples:\n sudo apt install $1 # Debian/Ubuntu\n sudo yum install $1 # CentOS"
}

enigma_has_mise() {
echo -ne "Checking for an installation of mise-en-place (https://mise.jdx.dev/)"
if check_exists "mise"; then
echo " Found!"
else
echo ""
fatal_error "ENiGMA½ requires mise-enplace to install dependencies."
fi
}

log() {
printf "${TIME_FORMAT} %b\n" "$*";
}
Expand All @@ -87,16 +91,18 @@ enigma_install_init() {
enigma_install_needs gcc
}

install_nvm() {
log "Installing nvm"
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
install_mise_en_place() {
curl https://mise.run | sh
eval ~/.local/bin/mise activate bash
}

configure_nvm() {
log "Installing Node ${ENIGMA_NODE_VERSION} via nvm"
. ~/.nvm/nvm.sh
nvm install ${ENIGMA_NODE_VERSION}
nvm use ${ENIGMA_NODE_VERSION}
install_node_runtime_environment() {
mise use --global node@$ENIGMA_NODE_VERSION
}

install_python_runtime_environment() {
mise settings python.compile=1
mise use --global python@$ENIGMA_PYTHON_VERSION
}

download_enigma_source() {
Expand Down Expand Up @@ -147,8 +153,9 @@ 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
}

Expand Down Expand Up @@ -185,17 +192,58 @@ ADDITIONAL ACTIONS ARE REQUIRED!

See docs for more information including other useful binaries!

4 - Start ENiGMA½ BBS!

./autoexec.sh

EndOfMessage
echo -e "\e[39m"
}

install_dependencies() {
enigma_install_init
install_mise_en_place
install_node_runtime_environment
install_python_runtime_environment
install_node_packages
}

install_bbs() {
download_enigma_source
copy_template_files
}

install_everything() {
install_dependencies
download_enigma_source
install_node_packages
copy_template_files
}

menu() {
title="Installation Options"
prompt="Pick an option:"
options=(
"Install Dependencies"
"Install ENiGMA½"
"Install Everything"
)

echo "$title"
PS3="$prompt "
select opt in "${options[@]}" "Quit"; do
case "$REPLY" in
1) enigma_install_init; install_dependencies; break;;
2) install_bbs; break;;
3) 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
7 changes: 7 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tools]
node = '18'
python = '3.10'

[env]
NODE_ENV = 'production'
_.python.venv = { path = ".venv", create = true }