Ticket #2904: PostgreSQL-8

File PostgreSQL-8, 792 bytes (added by decibel (Jim Nasby), 19 years ago)

New startup script

Line 
1#!/bin/sh
2#
3# DarwinPorts generated StartupItem
4#
5
6. /etc/rc.common
7
8PGDATA=${PGDATA:='/opt/local/var/db/pgsql/defaultdb'}
9if [ ! -d ${PGDATA} ]; then
10    ConsoleMessage "Error starting PostgreSQL-8: PGDATA directory '$PGDATA' doesn't exist!"
11    exit 1
12fi
13
14StartService ()
15{
16        if [ "${POSTGRESQL8:=-NO-}" = "-YES-" ]; then
17                ConsoleMessage "Starting PostgreSQL-8"
18                su -l postgres -c "exec /opt/local/bin/pg_ctl start -D $PGDATA -s -w"
19        fi
20}
21
22StopService ()
23{
24                ConsoleMessage "Stopping PostgreSQL-8"
25                su -l postgres -c "exec /opt/local/bin/pg_ctl stop -D $PGDATA -s -m fast"
26}
27
28RestartService ()
29{
30        if [ "${POSTGRESQL8:=-NO-}" = "-YES-" ]; then
31                ConsoleMessage "Restarting PostgreSQL-8"
32                su -l postgres -c "exec /opt/local/bin/pg_ctl restart -D $PGDATA -s -m fast"
33        fi
34}
35
36RunService "$1"