Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Last active August 29, 2015 14:00
Show Gist options
  • Save joseluisq/11165232 to your computer and use it in GitHub Desktop.
Save joseluisq/11165232 to your computer and use it in GitHub Desktop.
MongoDB Installer for Red Hat Enterprise, CentOS or Fedora 64-bit system
#!/bin/sh
# Mongodb Shell 64-bit System Installer
# OS: Red Hat Enterprise, CentOS, Fedora or a related linux system.
# Miscellaneous
B=`tput bold`
N=`tput sgr0`
# Checks if package is installed on system
FILEPATH="`type -P mongod`"
# Define 64-bit system repo
FILECONTENT="[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1"
# Define repo file path
FILEPATH="/etc/yum.repos.d/mongodb.repo"
# Check if repo exists
if [ -z $FILEPATH ];
then
echo "${B}MongoDB Installer"
echo "Initializing the installation..."
# Save mongodb.repo on repos directory
sudo echo "${FILECONTENT}" > "${FILEPATH}"
# Install MongoDB on system via yum
sudo yum install mongodb-org
# Start MongoDB service
sudo service mongod start
# Add MongoDB for automatically boot time.
sudo chkconfig mongod on
echo "${B}MongoDB${N} has been installed successfully!"
else
echo "${B}MongoDB${N} is already installed!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment