Files
runner-images/images/macos/provision/core/postgresql.sh
MaksimZhukov 310f692ea5 [macOS] Fix the issue with brew install (#2354)
* Update azure-cli installation

* Update curl installation

* Update git-lfs installation

* Add utils

* Update gnupg installation

* Add brew_install function

* Revert jq installation

* Add condition for the aws-sam-cli

* Add return to function, revert aws-sam-cli changes, rename brew_install function

* Fix typo

Co-authored-by: MaksimZhukov <v-mazhuk@microsoft.com>
2020-12-28 10:54:25 +03:00

27 lines
694 B
Bash

#!/bin/bash -e -o pipefail
source ~/utils/utils.sh
#Install latest version of postgresql
brew_smart_install "postgres"
#Service postgresql should be started before use.
brew services start postgresql
#Verify PostgreSQL is ready for accept incoming connections
echo "Check PostgreSQL service is running"
i=10
COMMAND='pg_isready'
while [ $i -gt 0 ]; do
echo "Check PostgreSQL service status"
eval $COMMAND && break
((i--))
if [ $i == 0 ]; then
echo "PostgreSQL service not ready, all attempts exhausted"
exit 1
fi
echo "PostgreSQL service not ready, wait 10 more sec, attempts left: $i"
sleep 10
done
#Stop postgresql
brew services stop postgresql