|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +## |
| 4 | +# PotgreSQL RDBMS Server |
| 5 | +## |
| 6 | + |
| 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: |
| 13 | +# |
| 14 | +# /Library/StartupItems/PostgreSQL/PostgreSQL |
| 15 | +# /Library/StartupItems/PostgreSQLStartupParameters.plist |
| 16 | +# |
| 17 | +# Next, add this line to the /etc/hostconfig file: |
| 18 | +# |
| 19 | +# POSTGRESQLSERVER=-YES- |
| 20 | +# |
| 21 | +# The startup bundle will now be read to go. To prevent this script from |
| 22 | +# starting PostgreSQL at system startup, simply change that line in |
| 23 | +# /etc/hostconfig to: |
| 24 | +# |
| 25 | +# POSTGRESQLSERVER=-NO- |
| 26 | +# |
| 27 | +# For more information on Darwin/Mac OS X startup bundles, see this article: |
| 28 | +# |
| 29 | +# http://www.opensource.apple.com/projects/documentation/howto/html/SystemStarter_HOWTO.html |
| 30 | +# |
| 31 | +# Created by David Wheeler, 2002. |
| 32 | + |
| 33 | +################################################################################ |
| 34 | +## EDIT FROM HERE |
| 35 | +################################################################################ |
| 36 | + |
| 37 | +# Installation prefix |
| 38 | +prefix=/usr/local/pgsql |
| 39 | + |
| 40 | +# Data directory |
| 41 | +PGDATA="/usr/local/pgsql/data" |
| 42 | + |
| 43 | +# Who to run pg_ctl as, should be "postgres". |
| 44 | +PGUSER=postgres |
| 45 | + |
| 46 | +# Where to keep a log file |
| 47 | +PGLOG="$PGDATA/serverlog" |
| 48 | + |
| 49 | +################################################################################ |
| 50 | +## STOP EDITING HERE |
| 51 | +################################################################################ |
| 52 | + |
| 53 | +# The path that is to be used for the script |
| 54 | +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
| 55 | + |
| 56 | +# What to use to start up the postmaster |
| 57 | +DAEMON="$prefix/bin/pg_ctl" |
| 58 | + |
| 59 | +. /etc/rc.common |
| 60 | + |
| 61 | +StartService () { |
| 62 | + if [ "${POSTGRESQLSERVER:=-NO-}" = "-YES-" ]; then |
| 63 | + ConsoleMessage "Starting PostgreSQL database server" |
| 64 | + sudo -u $PGUSER $DAEMON start -D "$PGDATA" -s -l $PGLOG |
| 65 | + fi |
| 66 | +} |
| 67 | + |
| 68 | +StopService () { |
| 69 | + ConsoleMessage "Stopping PostgreSQL database server" |
| 70 | + sudo -u $PGUSER $DAEMON stop -D "$PGDATA" -s -m fast |
| 71 | +} |
| 72 | + |
| 73 | +RestartService () { |
| 74 | + if [ "${POSTGRESQLSERVER:=-NO-}" = "-YES-" ]; then |
| 75 | + ConsoleMessage "Restarting PostgreSQL database server" |
| 76 | + sudo -u $PGUSER $DAEMON restart -D "$PGDATA" -s -m fast |
| 77 | + else |
| 78 | + StopService |
| 79 | + fi |
| 80 | +} |
| 81 | + |
| 82 | +RunService "$1" |
0 commit comments