From 1703e9dbf5463d0d9e6cdb55d7db3387e6e10b88 Mon Sep 17 00:00:00 2001 From: Daniel Valenzuela Date: Sat, 17 Feb 2024 01:03:43 -0300 Subject: [PATCH] fix: mongosh in provision.sh --- provision.sh | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/provision.sh b/provision.sh index 2f638c87924..ba1628edfad 100755 --- a/provision.sh +++ b/provision.sh @@ -159,34 +159,44 @@ 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 + 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()" + do + printf "." + sleep 1 + done else - until docker-compose exec -T mongo mongo --eval "db.serverStatus()" &> /dev/null + echo "Using new mongosh CLI" + until docker-compose exec -T mongo mongosh --eval "db.serverStatus()" + 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}" fi -# Run the service-specific provisioning script(s) -for service in $to_provision_ordered; do - echo -e "${GREEN} Provisioning ${service}...${NC}" - ./provision-"$service".sh - echo -e "${GREEN} Provisioned ${service}.${NC}" -done +# # Run the service-specific provisioning script(s) +# for service in $to_provision_ordered; do +# echo -e "${GREEN} Provisioning ${service}...${NC}" +# ./provision-"$service".sh +# echo -e "${GREEN} Provisioned ${service}.${NC}" +# done -docker image prune -f +# docker image prune -f echo -e "${GREEN}Provisioning complete!${NC}"