1#! /bin/sh
2
3# PostgreSQL boot time startup script for FreeBSD.  Copy this file to
4# /usr/local/etc/rc.d/postgresql.
5
6# Created through merger of the Linux start script by Ryan Kirkpatrick
7# and the script in the FreeBSD ports collection.
8
9# contrib/start-scripts/freebsd
10
11## EDIT FROM HERE
12
13# Installation prefix
14prefix=/usr/local/pgsql
15
16# Data directory
17PGDATA="/usr/local/pgsql/data"
18
19# Who to run the postmaster as, usually "postgres".  (NOT "root")
20PGUSER=postgres
21
22# Where to keep a log file
23PGLOG="$PGDATA/serverlog"
24
25## STOP EDITING HERE
26
27# The path that is to be used for the script
28PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
29
30# What to use to start up the postmaster.  (If you want the script to wait
31# until the server has started, you could use "pg_ctl start" here.)
32DAEMON="$prefix/bin/postmaster"
33
34# What to use to shut down the postmaster
35PGCTL="$prefix/bin/pg_ctl"
36
37# Only start if we can find the postmaster.
38test -x $DAEMON ||
39{
40	echo "$DAEMON not found"
41	exit 0
42}
43
44case $1 in
45    start)
46	su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
47	echo -n ' postgresql'
48	;;
49    stop)
50	su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
51	;;
52    restart)
53	su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
54	su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
55	;;
56    status)
57	su -l $PGUSER -c "$PGCTL status -D '$PGDATA'"
58	;;
59    *)
60	# Print help
61	echo "Usage: `basename $0` {start|stop|restart|status}" 1>&2
62	exit 1
63	;;
64esac
65
66exit 0
67