X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fpostgresql%2Ffiles%2Fvalidate_postgresql_connection.sh;fp=3rdparty%2Fmodules%2Fpostgresql%2Ffiles%2Fvalidate_postgresql_connection.sh;h=1c3506c71ad2bde9334072f9c5a48839a1131805;hb=a69999e580f8b3abd12446c2d6ad59e517651813;hp=0000000000000000000000000000000000000000;hpb=e7b6b352165009c385c52fcfe5a1055690dbfa4b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/postgresql/files/validate_postgresql_connection.sh b/3rdparty/modules/postgresql/files/validate_postgresql_connection.sh new file mode 100644 index 000000000..1c3506c71 --- /dev/null +++ b/3rdparty/modules/postgresql/files/validate_postgresql_connection.sh @@ -0,0 +1,34 @@ +#!/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=$((c+1)) +done + +echo 'Unable to connect to postgresql' + +exit 1