Last active
February 19, 2024 08:29
-
-
Save dpilafian/b07722347bb296cb6f3b6c300869d256 to your computer and use it in GitHub Desktop.
Quickly stand up of a local instance of MongoDB for development (without installing anything)
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 | |
################# | |
# Start MongoDB # | |
# WTFPL # | |
################# | |
# https://gist.github.com/dpilafian/b07722347bb296cb6f3b6c300869d256 | |
displayIntro() { | |
echo | |
echo "Start MongoDB" | |
echo "=============" | |
abortMsg="[ABORT] Install MongoDB:\n brew tap mongodb/brew\n brew install mongodb-community" | |
which mongod || { echo "$abortMsg"; exit; } | |
echo | |
} | |
shellInstructions() { | |
echo "To run the console (MongoDB Shell):" | |
echo " $ mongosh" | |
echo | |
} | |
startDb() { | |
cd ~/apps/mongo | |
mongod --version | |
echo "Data storage..." | |
mkdir -p db-store | |
ls -d $(pwd)/db-store | |
du -sh db-store | |
echo | |
echo "Launching..." | |
echo "Use ^C to shutdown" | |
ulimit -n 1000 #prevent "soft rlimits too low" warning | |
mongod --dbpath db-store | |
} | |
displayIntro | |
shellInstructions | |
startDb |
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 | |
################# | |
# Start MongoDB # | |
################# | |
# To make this file runnable: | |
# $ chmod +x *.sh.command | |
projectHome=$(cd $(dirname $0); pwd) | |
installFolder=~/apps/mongo | |
displayIntro() { | |
cd $projectHome | |
echo | |
echo "Install Start MongoDB" | |
echo "=====================" | |
pwd | |
echo | |
} | |
installScript() { | |
cd $projectHome | |
chmod +x *.sh.command | |
mkdir -p $installFolder | |
cp -v mongodb-start.sh.command $installFolder | |
which mongod | |
mongod --version | |
echo | |
echo "To start mongoDB, run:" | |
echo " $installFolder/mongodb-start.sh.command" | |
echo | |
} | |
displayIntro | |
installScript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment