Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b842726

Browse files
committed
I've simplified the Darwin/Mac OS X startup script I submitted earlier
in the year. This version has only the two files required by the Darwin startup bundle design. Plus the sh script now uses Darwin-standard functions to start up PostgreSQL, and it checks for the presence of a variable in /etc/hostconfig, as do other Darwin startup scripts. I suggest that a new directory be created, contrib/start-scripts/darwin, and that these two files be put into it. Folks who want to use the script can read the comments inside it to figure out how to use it. David Wheeler
1 parent 3bca6ca commit b842726

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
Description = "PostgreSQL Database Server";
3+
Provides = ("postgres database");
4+
Requires = ("Disks", "Resolver");
5+
Uses = ("NFS", "Network Time");
6+
OrderPreference = "None";
7+
Messages =
8+
{
9+
start = "Starting PostgreSQL database server";
10+
stop = "Stopping PostgreSQL database server";
11+
restart = "Restarting PostgreSQL database server";
12+
};
13+
}

0 commit comments

Comments
 (0)