#!/bin/ksh

daemon="/usr/local/bin/pg_ctl"
daemon_flags="-D /var/postgresql/data -w -l /var/postgresql/logfile"
daemon_user="_postgresql"
daemon_timeout=300

. /etc/rc.d/rc.subr

rc_usercheck=NO

# rc_exec is used because
# pg_ctl: cannot be run as root
# Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

rc_check() {
	rc_exec "${daemon} status ${daemon_flags}"
}

rc_reload() {
	rc_exec "${daemon} reload ${daemon_flags}"
}

rc_start() {
	rc_exec "${daemon} start ${daemon_flags}"
}

rc_stop() {
	rc_exec "${daemon} stop ${daemon_flags} -m fast" || \
		rc_exec "${daemon} stop ${daemon_flags} -m immediate"
}

rc_cmd $1
