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