module-postgresql/files/validate_postgresql_connection.sh
Michael Watters 291dbd9a87
Fix validation script to work with FreeBSD.
The validate_postgresql_connection.sh script was coded to rely on
bash which is not available by default in FreeBSD.  Updated script
to use /bin/sh which is a valid POSIX shell.
2016-04-21 16:52:32 -04:00

34 lines
349 B
Bash

#!/bin/sh
# usage is: validate_db_connection 2 50 psql
SLEEP=$1
TRIES=$2
PSQL=$3
STATE=1
c=1
while [ $c -le $TRIES ]
do
echo $c
if [ $c -gt 1 ]
then
echo 'sleeping'
sleep $SLEEP
fi
/bin/echo "SELECT 1" | $PSQL
STATE=$?
if [ $STATE -eq 0 ]
then
exit 0
fi
$c++
done
echo 'Unable to connect to postgresql'
exit 1