Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../usr/local/bin
File: validate_postgresql_connection.sh
#!/usr/bin/env bash
[0] Fix | Delete
[1] Fix | Delete
# usage is: validate_db_connection 2 50 psql
[2] Fix | Delete
[3] Fix | Delete
SLEEP=$1
[4] Fix | Delete
TRIES=$2
[5] Fix | Delete
PSQL=$3
[6] Fix | Delete
[7] Fix | Delete
STATE=1
[8] Fix | Delete
[9] Fix | Delete
for (( c=1; c<=$TRIES; c++ ))
[10] Fix | Delete
do
[11] Fix | Delete
echo $c
[12] Fix | Delete
if [ $c -gt 1 ]
[13] Fix | Delete
then
[14] Fix | Delete
echo 'sleeping'
[15] Fix | Delete
sleep $SLEEP
[16] Fix | Delete
fi
[17] Fix | Delete
[18] Fix | Delete
/bin/echo "SELECT 1" | $PSQL
[19] Fix | Delete
STATE=$?
[20] Fix | Delete
[21] Fix | Delete
if [ $STATE -eq 0 ]
[22] Fix | Delete
then
[23] Fix | Delete
exit 0
[24] Fix | Delete
fi
[25] Fix | Delete
done
[26] Fix | Delete
[27] Fix | Delete
echo 'Unable to connect to postgresql'
[28] Fix | Delete
[29] Fix | Delete
exit 1
[30] Fix | Delete
[31] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function