#!/bin/sh

# $FreeBSD: ports/japanese/postgresql7/files/pgsql.sh.tmpl,v 1.6 2001/05/08 12:36:01 knu Exp $
#
# For postmaster startup options, edit $PGDATA/postgresql.conf

PGBIN=/usr/local/bin

case $1 in
start)
    [ -d /usr/local/lib ] && /sbin/ldconfig -m /usr/local/lib
    [ -x ${PGBIN}/pg_ctl ] && {
	su -l pgsql -c \
	    '[ -d ${PGDATA} ] && exec /usr/local/bin/pg_ctl start -s -w -l ~pgsql/errlog'
	echo -n ' pgsql'
    }
    ;;

stop)
    [ -x ${PGBIN}/pg_ctl ] && {
	su -l pgsql -c 'exec /usr/local/bin/pg_ctl stop -s -m fast'
	echo -n ' pgsql'
    }
    ;;

status)
    [ -x ${PGBIN}/pg_ctl ] && {
	exec su -l pgsql -c 'exec /usr/local/bin/pg_ctl status'
    }
    ;;

*)
    echo "usage: `basename $0` {start|stop|status}" >&2
    exit 64
    ;;
esac
