Created
January 31, 2017 17:23
-
-
Save tikenn/5792917e36bfcce5c1f5568bb31e4a8b to your computer and use it in GitHub Desktop.
Installs MongoDB in a Node JS environment with a REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# -------------------------------------------------------------------------------------------- | |
# MongoDB install architecture | |
# -------------------------------------------------------------------------------------------- | |
# Installs MongoDB in a Node JS environment with a REST API | |
# - MongoDB | |
# - NodeJS | |
# - Node_module mongodb | |
# - Node_module mongo-rest | |
# | |
# -------------------------------------------------------------------------------------------- | |
# README | |
# -------------------------------------------------------------------------------------------- | |
# - Upgrade distribution to Ubuntu 16.04 LTS: do-release-upgrade | |
# - Run this script: ./mongo_node_install.sh | |
# - Insure that MongoDB is running: systemctl restart mongod | |
# - Start mongodb-rest service: mongodb-rest& | |
# | |
# ~ tikenn | |
# Check for sudo | |
if ! [[ "$EUID" = 0 ]] ; then | |
echo "Please run this script as super user (sudo)" | |
exit 0 | |
fi | |
# check for correct ubuntu distribution | |
if ! [[ $(lsb_release -r | grep -o -P "[0-9]{2}\.[0-9]{2}") = "16.04" ]] ; then | |
echo "Please update system to ubuntu 16.04" | |
exit 0 | |
fi | |
# install git if not already on the system | |
if ! which git > /dev/null ; then | |
apt-get install git | |
fi | |
# install mongo | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 | |
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list | |
apt-get update | |
apt-get install -y mongodb-org | |
systemctl start mongod | |
# install node js and npm | |
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - | |
apt-get update | |
apt-get install nodejs | |
# install mongodb driver for nodejs (just in case) | |
npm install -g mongodb | |
# install mongodb-rest service | |
git clone https://github.com/codecapers/mongodb-rest.git | |
cd mongodb-rest | |
npm install -g | |
# start mongodb-rest | |
mongodb-rest& |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment