Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 44c2283

Browse files
chore: add mongo 4.2 upgrde script (#828)
1 parent bdb8746 commit 44c2283

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

upgrade_mongo_4_2.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
# This script will upgrade a devstack that was previosly running Mongo DB 4.0 to MongoDB 4.0
5+
6+
. scripts/colors.sh
7+
8+
# Upgrade to mongo 4.2
9+
export MONGO_VERSION=4.2.14
10+
11+
echo
12+
echo -e "${GREEN}Restarting Mongo on version ${MONGO_VERSION}${NC}"
13+
make dev.up.mongo
14+
mongo_container="$(make --silent --no-print-directory dev.print-container.mongo)"
15+
16+
echo -e "${GREEN}Waiting for MongoDB...${NC}"
17+
until docker exec "$mongo_container" mongo --eval 'db.serverStatus()' &> /dev/null
18+
do
19+
printf "."
20+
sleep 1
21+
done
22+
23+
echo -e "${GREEN}MongoDB ready.${NC}"
24+
MONGO_VERSION_LIVE=$(docker exec -it "$mongo_container" mongo --quiet --eval "printjson(db.version())")
25+
MONGO_VERSION_COMPAT=$(docker exec -it "$mongo_container" mongo --quiet \
26+
--eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )['featureCompatibilityVersion'])")
27+
echo -e "${GREEN}Mongo Server version: ${MONGO_VERSION_LIVE}${NC}"
28+
echo -e "${GREEN}Mongo FeatureCompatibilityVersion version: ${MONGO_VERSION_COMPAT}${NC}"
29+
30+
if echo "${MONGO_VERSION_COMPAT}" | grep -q "4\.0" ; then
31+
echo -e "${GREEN}Upgrading FeatureCompatibilityVersion to 4.2${NC}"
32+
docker exec -it "$mongo_container" mongo --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"4.2\" } )"
33+
else
34+
echo -e "${GREEN}FeatureCompatibilityVersion already set to 4.2${NC}"
35+
fi

0 commit comments

Comments
 (0)