diff --git a/provision.sh b/provision.sh index 2f638c87924..aa9f6c5b5fd 100755 --- a/provision.sh +++ b/provision.sh @@ -159,22 +159,32 @@ docker-compose exec -T mysql57 bash -e -c "mysql -uroot mysql" < provision.sql if needs_mongo "$to_provision_ordered"; then echo -e "${GREEN}Waiting for MongoDB...${NC}" # mongo container and mongo process/shell inside the container + echo "Getting mongo shell ..." + set +e MONGO_SHELL=$(docker-compose exec -T mongo which mongosh) - if [[ $MONGO_SHELL ]] then - until docker-compose exec -T mongo mongosh --eval "db.serverStatus()" &> /dev/null - else + set -e + echo "Got mongo shell" + if [ -z "$MONGO_SHELL" ]; then + echo "Using old mongo CLI" until docker-compose exec -T mongo mongo --eval "db.serverStatus()" &> /dev/null + do + printf "." + sleep 1 + done + else + echo "Using new mongosh CLI" + until docker-compose exec -T mongo mongosh --eval "db.serverStatus()" &> /dev/null + do + printf "." + sleep 1 + done fi -t do - printf "." - sleep 1 - done echo -e "${GREEN}MongoDB ready.${NC}" echo -e "${GREEN}Creating MongoDB users...${NC}" - if [[ $MONGO_SHELL ]] then - docker-compose exec -T mongo bash -e -c "mongosh" < mongo-provision.js + if [ -z $MONGO_SHELL ]; then + docker-compose exec -T mongo bash -e -c "mongo" < mongo-provision.js; else - docker-compose exec -T mongo bash -e -c "mongo" < mongo-provision.js + docker-compose exec -T mongo bash -e -c "mongosh" < mongo-provision.js; fi else echo -e "${GREEN}MongoDB preparation not required; skipping.${NC}"