enigma-bbs/misc/install.sh

156 lines
4.7 KiB
Bash
Raw Normal View History

2016-08-22 21:55:05 +00:00
#!/usr/bin/env bash
{ # this ensures the entire script is downloaded before execution
2018-04-27 23:33:34 +00:00
ENIGMA_NODE_VERSION=${ENIGMA_NODE_VERSION:=10}
ENIGMA_BRANCH=master
ENIGMA_INSTALL_DIR=${ENIGMA_INSTALL_DIR:=$HOME/enigma-bbs}
ENIGMA_SOURCE=${ENIGMA_SOURCE:=https://github.com/NuSkooler/enigma-bbs.git}
2016-08-22 21:55:05 +00:00
TIME_FORMAT=`date "+%Y-%m-%d %H:%M:%S"`
WAIT_BEFORE_INSTALL=10
2016-08-22 21:55:05 +00:00
enigma_header() {
clear
2016-08-22 21:55:05 +00:00
cat << EndOfMessage
______
_____________________ _____ ____________________ __________\\_ /
\\__ ____/\\_ ____ \\ /____/ / _____ __ \\ / ______/ // /___jp!
// __|___// | \\// |// | \\// | | \\// \\ /___ /_____
/____ _____| __________ ___|__| ____| \\ / _____ \\
---- \\______\\ -- |______\\ ------ /______/ ---- |______\\ - |______\\ /__/ // ___/
/__ _\\
<*> ENiGMA½ // https://github.com/NuSkooler/enigma-bbs <*> /__/
ENiGMA½ will be installed to ${ENIGMA_INSTALL_DIR}, from source ${ENIGMA_SOURCE}.
2017-01-30 02:55:48 +00:00
ENiGMA½ requires Node.js. Version ${ENIGMA_NODE_VERSION}.x current will be installed via nvm. If you already have nvm installed, this install script will update it to the latest version.
2016-08-22 21:55:05 +00:00
If this isn't what you were expecting, hit CTRL-C now. Installation will continue in ${WAIT_BEFORE_INSTALL} seconds...
2016-08-22 21:55:05 +00:00
EndOfMessage
sleep ${WAIT_BEFORE_INSTALL}
2016-08-22 21:55:05 +00:00
}
2018-11-11 01:11:00 +00:00
fatal_error() {
printf "${TIME_FORMAT} \e[41mERROR:\033[0m %b\n" "$*" >&2;
exit 1
}
2016-08-22 21:55:05 +00:00
enigma_install_needs() {
2018-11-11 01:19:38 +00:00
command -v $1 >/dev/null 2>&1 || fatal_error "ENiGMA½ requires $1 but it's not installed. Please install it and restart the installer."
2016-08-22 21:55:05 +00:00
}
log() {
printf "${TIME_FORMAT} %b\n" "$*";
}
enigma_install_init() {
log "Checking git installation"
enigma_install_needs git
log "Checking curl installation"
enigma_install_needs curl
log "Checking Python installation"
enigma_install_needs python
2016-08-22 21:55:05 +00:00
}
install_nvm() {
log "Installing nvm"
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
}
configure_nvm() {
log "Installing Node ${ENIGMA_NODE_VERSION} via nvm"
. ~/.nvm/nvm.sh
nvm install ${ENIGMA_NODE_VERSION}
nvm use ${ENIGMA_NODE_VERSION}
}
download_enigma_source() {
2018-11-11 01:19:38 +00:00
local INSTALL_DIR
INSTALL_DIR=${ENIGMA_INSTALL_DIR}
if [ -d "$INSTALL_DIR/.git" ]; then
log "ENiGMA½ is already installed in $INSTALL_DIR, trying to update using git"
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null ||
fatal_error "Failed to update ENiGMA½, run 'git fetch' in $INSTALL_DIR yourself."
else
log "Downloading ENiGMA½ from git to '$INSTALL_DIR'"
mkdir -p "$INSTALL_DIR"
command git clone ${ENIGMA_SOURCE} "$INSTALL_DIR" ||
fatal_error "Failed to clone ENiGMA½ repo. Please report this!"
fi
}
is_arch_arm() {
local ARCH=`arch`
if [[ $ARCH == "arm"* ]]; then
2018-11-11 01:46:43 +00:00
true
2018-11-11 01:19:38 +00:00
else
2018-11-11 01:46:43 +00:00
false
2018-11-11 01:19:38 +00:00
fi
2016-08-22 21:55:05 +00:00
}
2018-11-11 01:19:38 +00:00
extra_npm_install_args() {
2018-11-11 01:46:43 +00:00
if is_arch_arm ; then
2018-11-11 01:11:00 +00:00
echo "--build-from-source"
else
echo ""
fi
}
2016-08-22 21:55:05 +00:00
install_node_packages() {
2018-11-11 03:26:11 +00:00
log "Installing required Node packages..."
log "Note that on some systems such as RPi, this can take a VERY long time. Be patient!"
2016-08-22 21:55:05 +00:00
cd ${ENIGMA_INSTALL_DIR}
2018-11-11 01:11:00 +00:00
local EXTRA_NPM_ARGS=$(extra_npm_install_args)
git checkout ${ENIGMA_BRANCH} && npm install ${EXTRA_NPM_ARGS}
2016-08-22 21:55:05 +00:00
if [ $? -eq 0 ]; then
2018-11-11 01:19:38 +00:00
log "npm package installation complete"
2016-08-22 21:55:05 +00:00
else
2018-11-11 01:19:38 +00:00
fatal_error "Failed to install ENiGMA½ npm packages. Please report this!"
2016-08-22 21:55:05 +00:00
fi
}
enigma_footer() {
log "ENiGMA½ installation complete!"
echo -e "\e[33m"
cat << EndOfMessage
2017-06-01 21:40:32 +00:00
If this is the first time you've installed ENiGMA½, you now need to generate a minimal configuration. To do so, run the following commands (note: if you did not already have node.js installed, you may need to log out/back in to refresh your path):
2017-01-30 02:55:48 +00:00
cd ${ENIGMA_INSTALL_DIR}
2017-06-01 21:39:26 +00:00
./oputil.js config new
2017-01-30 02:55:48 +00:00
Additionally, the following support binaires are recommended:
7zip: Archive support
Debian/Ubuntu : apt-get install p7zip
CentOS : yum install p7zip
Lha: Archive support
Debian/Ubuntu : apt-get install lhasa
2017-01-31 04:54:00 +00:00
Arj: Archive support
Debian/Ubuntu : apt-get install arj
2017-01-30 02:55:48 +00:00
sz/rz: Various X/Y/Z modem support
Debian/Ubuntu : apt-get install lrzsz
CentOS : yum install lrzsz
See docs for more information!
EndOfMessage
echo -e "\e[39m"
2016-08-22 21:55:05 +00:00
}
enigma_header
enigma_install_init
install_nvm
configure_nvm
download_enigma_source
install_node_packages
enigma_footer
2017-06-01 21:39:26 +00:00
} # this ensures the entire script is downloaded before execution