#!/bin/bash

#ip:port:database:username:password
echo "${1}:${2}:${3}:${4}:${5}" > ~/.pgpass
chmod 0600 ~/.pgpass

psql -U ${4} ${3} -h ${1} -p ${2} -c "select pg_is_in_recovery();"|awk 'NR==3'