Last active
February 9, 2018 07:55
-
-
Save mansurali901/94fdf91d6474429234e9dac3ee5abfeb to your computer and use it in GitHub Desktop.
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
# This script install Mongo 3.4 in Ubuntu 16.04 | |
# Author Mansur Ul Hasan | |
# [email protected] | |
SetupMongo3_4 () { | |
# Adding gpg key | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 | |
# Adding MongoDB repository | |
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list | |
# System APT update | |
apt-get update -y | |
# Installing MongoDB | |
apt-get install -y mongodb-org | |
# Starting Mongo | |
service mongod start | |
# Checking Mongo Status | |
service mongod status | |
echo " | |
################################################### | |
Mongo DB 3.4 has been installed | |
###################################################" | |
} | |
SetupMongo3_2 () { | |
# Adding gpg key | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 | |
# Adding MongoDB repository | |
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 | |
# System APT update | |
apt-get update -y | |
# Installing MongoDB | |
apt-get install -y mongodb-org | |
# Adding Service | |
echo " | |
[Unit] | |
Description=High-performance, schema-free document-oriented database | |
After=network.target | |
[Service] | |
User=mongodb | |
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf | |
[Install] | |
WantedBy=multi-user.target" >> /etc/systemd/system/mongodb.service | |
# Starting Mongo | |
systemctl start mongodb | |
# Checking Mongo Status | |
systemctl status mongodb | |
echo " | |
################################################### | |
Mongo DB 3.2.15 has been installed | |
################################################### | |
" | |
} | |
read -p "Enter the version you wants to install : " ver | |
case $ver in | |
3.4) | |
SetupMongo3_4 | |
;; | |
3.2) | |
SetupMongo3_2 | |
;; | |
*) | |
echo "Please enter valid version | |
3.2 To install Mongo Version 3.2 | |
3.4 To install Mongo Version 3.4 | |
" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment