]> granicus.if.org Git - postgresql/blob - contrib/start-scripts/freebsd
Adjust postmaster to recognize that a lockfile containing its parent's PID
[postgresql] / contrib / start-scripts / freebsd
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 # $PostgreSQL: pgsql/contrib/start-scripts/freebsd,v 1.4 2004/10/01 18:30:21 tgl Exp $
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 the postmaster 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 the postmaster (we do NOT use pg_ctl for this,
31 # as it adds no value and can cause the postmaster to misrecognize a stale
32 # lock file)
33 DAEMON="$prefix/bin/postmaster"
34
35 # What to use to shut down the postmaster
36 PGCTL="$prefix/bin/pg_ctl"
37
38 # Only start if we can find the postmaster.
39 test -x "$DAEMON" || exit 0
40
41 case $1 in
42     start)
43         su -l $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
44         echo -n ' postgresql'
45         ;;
46     stop)
47         su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
48         ;;
49     restart)
50         su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
51         su -l $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
52         ;;
53     status)
54         su -l $PGUSER -c "$PGCTL status -D '$PGDATA'"
55         ;;
56     *)
57         # Print help
58         echo "Usage: `basename $0` {start|stop|restart|status}" 1>&2
59         exit 1
60         ;;
61 esac
62
63 exit 0