Skip to content

Instantly share code, notes, and snippets.

@rudolphjacksonm
Created December 17, 2021 14:47
Show Gist options
  • Save rudolphjacksonm/b8dc86a7c805d0f20a6cb6abeaf84d9e to your computer and use it in GitHub Desktop.
Save rudolphjacksonm/b8dc86a7c805d0f20a6cb6abeaf84d9e to your computer and use it in GitHub Desktop.
Prep Azure DevOps Agent for CosmosDB Key Rotation
#!/bin/bash
function install_mongo_shell() {
# Installation instructions: https://docs.mongodb.com/mongodb-shell/install/
# Check the Ubuntu version used and modify installation accordingly
osRelease=$(cat /etc/os-release | grep 'VERSION=')
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
case $osRelease in
*"Xenial"*)
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
;;
*"Bionic"*)
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
;;
*"Focal"*)
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
;;
*)
echo "Unknown OS version detected (${osRelease}), exiting..."
exit 1
;;
esac
sudo apt-get update
sudo apt-get install -y mongodb-mongosh
}
install_mongo_shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment