With a little refinement, I have a new script for those who install PostgresSQL from a dmg package as me. This is my pgsql_svr.sh
#!/bin/sh
start(){
echo "Starting PostgreSQL"
sudo -u postgres /Library/PostgreSQL/9.1/bin/postmaster -i -D /Library/PostgreSQL/9.1/data &
}
stop(){
echo "Stopping PostgreSQL"
sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl -D /Library/PostgreSQL/9.1/data stop
}
restart(){
echo "Restarting PostgreSQL"
stop
start
}
usage(){
NAME=`basename $0`
echo "Uasage: "
echo "$NAME start|stop|restart"
}
if [ "$1" = "start" ] || [ "$1" = "stop" ] || [ "$1" = "restart" ]; then
$1
else
usage
fi
NOTE: You need
sudo
to run this shell script.