Created
May 9, 2019 13:24
-
-
Save AlessandroVaccarino/4c96903479fcad67d753433b94be22f6 to your computer and use it in GitHub Desktop.
A simple shell to install the last version of Ubuntu Enterprise on Ubuntu
This file contains 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
# Install MongoDB Enterprise on Ubuntu | |
# https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/#install-mongodb-enterprise-on-ubuntu | |
# Specify MongoDB version (leave blank for latest version) | |
export MONGODB_VERSION="" | |
# Get OS Version | |
. /etc/os-release | |
echo "----> $PRETTY_NAME ($ID - $VERSION)" | |
# Import the public key used by the package management system. | |
# https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/#import-the-public-key-used-by-the-package-management-system | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 | |
# Create a /etc/apt/sources.list.d/mongodb-enterprise.list file for MongoDB. | |
# https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/#create-a-etc-apt-sources-list-d-mongodb-enterprise-list-file-for-mongodb | |
if [ "$ID" = "ubuntu" ]; then | |
if [ "$VERSION_ID" = "18.04" ]; then | |
echo "----> VERSION 18.04 DETECTED" | |
echo "deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu bionic/mongodb-enterprise/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list | |
elif [ "$VERSION_ID" = "16.04" ]; then | |
echo "----> VERSION 16.04 DETECTED" | |
echo "deb [ arch=amd64,arm64,ppc64el,s390x ] http://repo.mongodb.com/apt/ubuntu xenial/mongodb-enterprise/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list | |
elif [ "$VERSION_ID" = "14.04" ]; then | |
echo "----> VERSION 14.04 DETECTED" | |
echo "deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu trusty/mongodb-enterprise/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list | |
else | |
echo "----> OS $VERSION_ID of $ID not supported currently!" | |
exit 1 | |
fi | |
fi | |
# Reload local package database. | |
# https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/#reload-local-package-database | |
sudo apt-get update | |
# Install the MongoDB Enterprise packages. | |
# https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/#install-the-mongodb-enterprise-packages | |
if [ "$MONGODB_VERSION" = "" ]; then | |
echo "----> Installing latest version of MongoDB" | |
sudo apt-get install -y mongodb-enterprise | |
else | |
echo "----> Installing version $MONGODB_VERSION of MongoDB" | |
sudo apt-get install -y mongodb-enterprise=$MONGODB_VERSION mongodb-enterprise-server=$MONGODB_VERSION mongodb-enterprise-shell=$MONGODB_VERSION mongodb-enterprise-mongos=$MONGODB_VERSION mongodb-enterprise-tools=$MONGODB_VERSION | |
fi | |
# Start MongoDB. | |
# https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/#start-mongodb | |
sudo service mongod start | |
# Set Mongo as auto-start | |
sudo systemctl enable mongod.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment