Skip to content

Instantly share code, notes, and snippets.

@ticidesign
Created April 26, 2020 01:40
Show Gist options
  • Save ticidesign/c7bc490a50cbcd5f2052bfee82d58b9e to your computer and use it in GitHub Desktop.
Save ticidesign/c7bc490a50cbcd5f2052bfee82d58b9e to your computer and use it in GitHub Desktop.
CI for switching MongoDB from v3.4 to latest
# Switching from v3.4 to latest
select_lastest() {
# Stop and unlink 3.4
brew services stop mongodb@3.4
brew unlink mongodb@3.4
# Link last version
brew unlink mongodb && brew link mongodb
# Update mongo logs and database paths
sed -i.3.4 's:/mongodb-3\.4/:/mongodb/:' /usr/local/etc/mongod.conf
# Restart the service
brew services restart mongodb
}
select_34() {
# Stop and Unlink
brew services stop mongodb
brew unlink mongodb
# Link 3.4
brew unlink mongodb@3.4 && brew link mongodb@3.4 --force
# Update mongo logs and database paths
sed -i.latest 's:/mongodb/:/mongodb-3\.4/:' /usr/local/etc/mongod.conf
# Restart the service
brew services restart mongodb@3.4
}
if [ $1 == 'latest' ]
then
select_lastest
elif [ $1 == '3.4' ]
then
select_34
else
printf Passed: $1
printf Usage: mongo-use [latest|3.4]
fi
printf Current mongo version:
mongo --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment