2001-02-10 00:13:23 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
# PostgreSQL boot time startup script for FreeBSD. Copy this file to
|
|
|
|
# /usr/local/etc/rc.d/postgresql.
|
|
|
|
|
|
|
|
# Created through merger of the Linux start script by Ryan Kirkpatrick
|
|
|
|
# and the script in the FreeBSD ports collection.
|
|
|
|
|
2010-09-20 22:08:53 +02:00
|
|
|
# contrib/start-scripts/freebsd
|
2001-02-10 00:13:23 +00:00
|
|
|
|
|
|
|
## EDIT FROM HERE
|
|
|
|
|
|
|
|
# Installation prefix
|
|
|
|
prefix=/usr/local/pgsql
|
|
|
|
|
|
|
|
# Data directory
|
|
|
|
PGDATA="/usr/local/pgsql/data"
|
|
|
|
|
2023-01-26 10:48:32 +01:00
|
|
|
# Who to run postgres as, usually "postgres". (NOT "root")
|
2001-02-10 00:13:23 +00:00
|
|
|
PGUSER=postgres
|
|
|
|
|
|
|
|
# Where to keep a log file
|
|
|
|
PGLOG="$PGDATA/serverlog"
|
|
|
|
|
|
|
|
## STOP EDITING HERE
|
|
|
|
|
|
|
|
# The path that is to be used for the script
|
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
|
2023-01-26 10:48:32 +01:00
|
|
|
# What to use to start up postgres. (If you want the script to wait
|
2017-01-13 12:00:00 -05:00
|
|
|
# until the server has started, you could use "pg_ctl start" here.)
|
2023-01-26 10:48:32 +01:00
|
|
|
DAEMON="$prefix/bin/postgres"
|
2001-02-10 00:13:23 +00:00
|
|
|
|
2023-01-26 10:48:32 +01:00
|
|
|
# What to use to shut down postgres
|
2004-10-01 18:30:25 +00:00
|
|
|
PGCTL="$prefix/bin/pg_ctl"
|
|
|
|
|
2023-01-26 10:48:32 +01:00
|
|
|
# Only start if we can find postgres.
|
2010-02-23 22:15:35 +00:00
|
|
|
test -x $DAEMON ||
|
|
|
|
{
|
|
|
|
echo "$DAEMON not found"
|
2010-02-23 22:17:25 +00:00
|
|
|
exit 0
|
2010-02-23 22:15:35 +00:00
|
|
|
}
|
2001-02-10 00:13:23 +00:00
|
|
|
|
|
|
|
case $1 in
|
|
|
|
start)
|
2017-11-06 07:11:10 -08:00
|
|
|
su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
|
2001-02-10 00:13:23 +00:00
|
|
|
echo -n ' postgresql'
|
|
|
|
;;
|
|
|
|
stop)
|
2017-01-13 12:00:00 -05:00
|
|
|
su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
|
2001-02-10 00:13:23 +00:00
|
|
|
;;
|
|
|
|
restart)
|
2017-01-13 12:00:00 -05:00
|
|
|
su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
|
2017-11-06 07:11:10 -08:00
|
|
|
su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
|
2001-02-10 00:13:23 +00:00
|
|
|
;;
|
|
|
|
status)
|
2004-10-01 18:30:25 +00:00
|
|
|
su -l $PGUSER -c "$PGCTL status -D '$PGDATA'"
|
2001-02-10 00:13:23 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Print help
|
|
|
|
echo "Usage: `basename $0` {start|stop|restart|status}" 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|