| 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 |
| 14 |
prefix=/usr/local/pgsql |
| 15 |
|
| 16 |
# Data directory |
| 17 |
PGDATA="/usr/local/pgsql/data" |
| 18 |
|
| 19 |
# Who to run postgres as, usually "postgres". (NOT "root") |
| 20 |
PGUSER=postgres |
| 21 |
|
| 22 |
# Where to keep a log file |
| 23 |
PGLOG="$PGDATA/serverlog" |
| 24 |
|
| 25 |
## STOP EDITING HERE |
| 26 |
|
| 27 |
# The path that is to be used for the script |
| 28 |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
| 29 |
|
| 30 |
# What to use to start up postgres. (If you want the script to wait |
| 31 |
# until the server has started, you could use "pg_ctl start" here.) |
| 32 |
DAEMON="$prefix/bin/postgres" |
| 33 |
|
| 34 |
# What to use to shut down postgres |
| 35 |
PGCTL="$prefix/bin/pg_ctl" |
| 36 |
|
| 37 |
# Only start if we can find postgres. |
| 38 |
test -x $DAEMON || |
| 39 |
{ |
| 40 |
echo "$DAEMON not found" |
| 41 |
exit 0 |
| 42 |
} |
| 43 |
|
| 44 |
case $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 |
;; |
| 64 |
esac |
| 65 |
|
| 66 |
exit 0 |