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

Commit

Permalink
fix: mongosh in provision.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVZ96 committed Feb 17, 2024
1 parent 29b08cd commit 1703e9d
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 1703e9d

Please sign in to comment.