summaryrefslogtreecommitdiff
path: root/contrib/start-scripts
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-12-09 21:26:09 +0000
committerBruce Momjian <bruce@momjian.us>2002-12-09 21:26:09 +0000
commitb842726fc7a2b2f45b567eb03610ab71fad8d89a (patch)
tree06365c7702ac000834c25acbff2724fd3d890649 /contrib/start-scripts
parent3bca6ca61c46931f8c5b7b0afa69f95aea3d2232 (diff)
downloadpostgresql-b842726fc7a2b2f45b567eb03610ab71fad8d89a.tar.gz
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
Diffstat (limited to 'contrib/start-scripts')
-rwxr-xr-xcontrib/start-scripts/PostgreSQL.darwin82
-rw-r--r--contrib/start-scripts/StartupParameters.plist.darwin13
2 files changed, 95 insertions, 0 deletions
diff --git a/contrib/start-scripts/PostgreSQL.darwin b/contrib/start-scripts/PostgreSQL.darwin
new file mode 100755
index 0000000000..987c162f29
--- /dev/null
+++ b/contrib/start-scripts/PostgreSQL.darwin
@@ -0,0 +1,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"
diff --git a/contrib/start-scripts/StartupParameters.plist.darwin b/contrib/start-scripts/StartupParameters.plist.darwin
new file mode 100644
index 0000000000..0a2f3ba438
--- /dev/null
+++ b/contrib/start-scripts/StartupParameters.plist.darwin
@@ -0,0 +1,13 @@
+{
+ Description = "PostgreSQL Database Server";
+ Provides = ("postgres database");
+ Requires = ("Disks", "Resolver");
+ Uses = ("NFS", "Network Time");
+ OrderPreference = "None";
+ Messages =
+ {
+ start = "Starting PostgreSQL database server";
+ stop = "Stopping PostgreSQL database server";
+ restart = "Restarting PostgreSQL database server";
+ };
+}