opt-cc/docs/infra/3rd-party-install.sh

51 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
cd $(dirname $0)
echo "########################################################"
echo "###### INSTALLING ALL REQUIRED 3RD-PARTY SOFTWARE ######"
echo "########################################################"
echo "# MONGO DB COMMUNITY"
echo "# NPM"
echo "# NODE"
# mongodb key & repo
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | \
sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
# install from apt
sudo apt-get update
sudo apt-get install -y mongodb-org npm
# enable mongod for autostart
sudo systemctl enable mongod.service
# install latest node version
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
source ~/.nvm/nvm.sh
nvm install stable
sudo ln -sf ~/.nvm/versions/node/$(node -v)/bin/node /usr/bin/node
# upgrade to latest npm version
sudo npm install -g npm@latest
if [ "${1}" == "prod" ]; then
echo "########################################################"
echo "################ SETTING UP APPLICATION ################"
echo "########################################################"
cd ./../..
npm install
npm run deploy-static:prod
echo "########################################################"
echo "####### INSTALLING PM2 AND INGRAIN AUTO STARTUP ########"
echo "########################################################"
sudo npm install -g pm2
pm2 start pm2-start.json
pm2 save
pm2 startup systemd
fi
echo " ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑"
echo "IMPORTANT: Run the sudo command printed above to finish the pm2 setup"