4 # PostgreSQL RDBMS Server
7 # PostgreSQL boot time startup script for Darwin/Mac OS X. To install, change
8 # the "prefix", "PGDATA", "PGUSER", and "PGLOG" variables below as
9 # necessary. Next, create a new directory, "/Library/StartupItems/PostgreSQL".
10 # Then copy this script and the accompanying "StartupParameters.plist" file
11 # into that directory. The name of this script file *must* be the same as the
12 # directory it is in. So you'll end up with these two files:
14 # /Library/StartupItems/PostgreSQL/PostgreSQL
15 # /Library/StartupItems/PostgreSQL/StartupParameters.plist
17 # Next, add this line to the /etc/hostconfig file:
21 # The startup bundle will now be ready to go. To prevent this script from
22 # starting PostgreSQL at system startup, simply change that line in
23 # /etc/hostconfig back to:
27 # For more information on Darwin/Mac OS X startup bundles, see this article:
29 # http://www.opensource.apple.com/projects/documentation/howto/html/SystemStarter_HOWTO.html
31 # Created by David Wheeler, 2002.
33 # modified by Ray Aspeitia 12-03-2003 :
34 # added log rotation script to db startup
35 # modified StartupParameters.plist "Provides" parameter to make it easier to
36 # start and stop with the SystemStarter utitlity
38 # use the below command in order to correctly start/stop/restart PG with log rotation script:
39 # SystemStarter [start|stop|restart] PostgreSQL
41 ################################################################################
43 ################################################################################
46 prefix
="/usr/local/pgsql"
49 PGDATA
="/usr/local/pgsql/data"
51 # Who to run the postmaster as, usually "postgres". (NOT "root")
54 # the logfile path and name (NEEDS to be writeable by PGUSER)
55 PGLOG
="${PGDATA}/logs/logfile"
57 # do you want to rotate the log files, 1=true 0=false
60 # logfile rotate in seconds
64 ################################################################################
66 ################################################################################
68 # The path that is to be used for the script
69 PATH
="$prefix/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
71 # What to use to start up the postmaster (we do NOT use pg_ctl for this,
72 # as it adds no value and can cause the postmaster to misrecognize a stale
74 DAEMON
="$prefix/bin/postmaster"
76 # What to use to shut down the postmaster
77 PGCTL
="$prefix/bin/pg_ctl"
79 # The apache log rotation utility
80 LOGUTIL
="/usr/sbin/rotatelogs"
85 if [ "${POSTGRESQL:=-NO-}" = "-YES-" ]; then
86 ConsoleMessage
"Starting PostgreSQL database server"
87 if [ "${ROTATELOGS}" = "1" ]; then
88 sudo
-u $PGUSER sh
-c "${DAEMON} -D '${PGDATA}' 2>&1 | ${LOGUTIL} '${PGLOG}' ${ROTATESEC} &"
90 sudo
-u $PGUSER sh
-c "${DAEMON} -D '${PGDATA}' &" >>$PGLOG 2>&1
96 ConsoleMessage
"Stopping PostgreSQL database server"
97 sudo
-u $PGUSER $PGCTL stop
-D "$PGDATA" -s -m fast
101 if [ "${POSTGRESQL:=-NO-}" = "-YES-" ]; then
102 ConsoleMessage
"Restarting PostgreSQL database server"
103 # should match StopService:
104 sudo
-u $PGUSER $PGCTL stop
-D "$PGDATA" -s -m fast
105 # should match StartService:
106 if [ "${ROTATELOGS}" = "1" ]; then
107 sudo
-u $PGUSER sh
-c "${DAEMON} -D '${PGDATA}' 2>&1 | ${LOGUTIL} '${PGLOG}' ${ROTATESEC} &"
109 sudo
-u $PGUSER sh
-c "${DAEMON} -D '${PGDATA}' &" >>$PGLOG 2>&1