Created
August 2, 2023 20:47
-
-
Save Mitrajit/591b2cf43150fcae91b8265c547b1b59 to your computer and use it in GitHub Desktop.
Installing mongo db 6.0.8 in 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
#!/bin/bash | |
# Function to install MongoDB | |
install_mongodb() { | |
echo "Importing the public key used by the package management system." | |
sudo apt-get install -y gnupg curl | |
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \ | |
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor | |
echo "Creating a list file for MongoDB." | |
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list | |
echo "Reloading local package database." | |
sudo apt-get update | |
echo "Installing MongoDB Packages." | |
sudo apt-get install -y mongodb-org | |
echo "Starting MongoDB Service." | |
sudo systemctl start mongod | |
echo "Enabling MongoDB Service." | |
sudo systemctl enable mongod | |
echo "Checking the status of MongoDB Service." | |
sudo systemctl status mongod | |
} | |
# Function to remove the script file itself | |
remove_script() { | |
echo "Removing the script." | |
rm "$0" | |
} | |
# Main script execution | |
install_mongodb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment