#!/bin/bash TRY=10 svc -u /service/postgresql while ! psql -U postgresql -c '\q' template1 &> /dev/null; do echo "Waiting for postgresql to start.. ($TRY)" sleep 5 (( TRY-- )) if [ $TRY -eq 0 ]; then syn3-state postgresql CAUTION "Startup error" svc -d /service/postgresql exit 1 fi done syn3-state postgresql OK "Started"