#!/bin/sh

# check to see if PostgreSQL is running.

x=`ps -auxwc | grep postgres |grep postmaster | awk -F" " '{print $2}'`
if /bin/test -n "$x"
then
	# call shutdown...
	if /bin/test -f '/Library/PostgreSQL8/bin/pg_ctl' 
	then
		su -m postgres -c '/Library/PostgreSQL8/bin/pg_ctl stop -D /Library/PostgreSQL8/data'
	fi
	
	x=`ps -aux | grep postgres | grep postmaster | awk -F" " '{print $2}'`
	if /bin/test "$x"
	then
		set $x
		kill -9 $x
	fi
fi
exit 0
