5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
26 .
/lib
/svc
/share
/smf_include.sh
29 val
=`svcprop -c -p $1 $SMF_FMRI`
30 [ -n "$val" ] && echo $val
34 if [ ! -d $PGDATA ]; then
35 echo "Error: postgresql/data directory $PGDATA does not exist"
36 exit $SMF_EXIT_ERR_CONFIG
39 if [ ! -w $PGDATA ]; then
40 echo "Error: postgresql/data directory $PGDATA is not writable by postgres"
41 exit $SMF_EXIT_ERR_CONFIG
44 if [ ! -d $PGDATA/base
-o ! -d $PGDATA/global
-o ! -f $PGDATA/PG_VERSION
]; then
45 echo "Error: postgresql/data directory $PGDATA is not empty, nor is it a valid PostgreSQL data directory"
46 exit $SMF_EXIT_ERR_CONFIG
50 if [ -z "$SMF_FMRI" ]; then
51 echo "Error: SMF framework variables are not initialized."
55 PGBIN
=`getproparg postgresql/bin`
56 PGDATA
=`getproparg postgresql/data`
57 PGUSER
=`getproparg method_context/user`
59 if [ -z "$PGDATA" ]; then
60 echo "Error: postgresql/data property not set"
61 exit $SMF_EXIT_ERR_CONFIG
64 if [ -z "$PGBIN" ]; then
65 echo "Error: postgresql/bin property not set"
66 exit $SMF_EXIT_ERR_CONFIG
69 if [ -z "$PGUSER" ]; then
70 echo "Error: method_context/user property not set"
71 exit $SMF_EXIT_ERR_CONFIG
77 $PGBIN/pg_ctl
-D $PGDATA start
81 status
=`$PGBIN/pg_ctl -D $PGDATA status | /bin/grep PID`
82 $PGBIN/pg_ctl
-D $PGDATA stop
-m fast
83 if [ -z "$status" ]; then
84 pattern
="$PGBIN/postgres -D $PGDATA"
85 /bin
/pgrep
-u $PGUSER -f "$pattern" > /dev
/null
2>&1
87 echo "Sending immediate shutdown signal."
88 /bin
/pkill
-QUIT -u $PGUSER -f "$pattern"
94 $PGBIN/pg_ctl
-D $PGDATA reload
98 echo "Usage: $0 {start|stop|refresh}"