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
28 # SMF_FMRI is the name of the target service. This allows multiple instances
29 # to use the same script.
32 val
=`svcprop -p $1 $SMF_FMRI`
33 [ -n "$val" ] && echo $val
37 if [ ! -d $PGDATA ]; then
38 echo "Error: postgresql_14/data directory $PGDATA does not exist"
39 exit $SMF_EXIT_ERR_CONFIG
42 if [ ! -w $PGDATA ]; then
43 echo "Error: postgresql_14/data directory $PGDATA is not writable by postgres"
44 exit $SMF_EXIT_ERR_CONFIG
47 if [ "$PGINIT" = "false" ]; then
48 echo "Notice: postgresql_14/data directory $PGDATA is not initialized"
49 echo " Calling '$PGBIN/initdb -D $PGDATA' to initialize"
50 $PGBIN/initdb
-D $PGDATA
52 echo "Error: initdb failed"
53 echo "Hint : If database is already initialized set postgresql_14/initialized property to true."
54 echo " svccfg -s $SMF_FMRI \"setprop postgresql_14/initialized = boolean: true\""
55 echo " svccfg -s $SMF_FMRI refresh"
58 svccfg
-s $SMF_FMRI "setprop postgresql_14/initialized = boolean: true"
59 svccfg
-s $SMF_FMRI refresh
62 if [ ! -d $PGDATA/base
-o ! -d $PGDATA/global
-o ! -f $PGDATA/PG_VERSION
]; then
63 if [ `ls -a $PGDATA | wc -w` -le 2 ]; then
64 echo "Error: postgresql_14/data directory $PGDATA is empty, but it should be initialized"
65 echo "Hint : check your mountpoints"
67 echo "Error: postgresql_14/data directory $PGDATA is not empty, nor is it a valid PostgreSQL data directory"
69 exit $SMF_EXIT_ERR_CONFIG
73 PGBIN
=`getproparg postgresql_14/bin`
74 PGDATA
=`getproparg postgresql_14/data`
75 PGLOG
=`getproparg postgresql_14/log`
76 PGINIT
=`getproparg postgresql_14/initialized`
78 if [ -z $SMF_FMRI ]; then
79 echo "Error: SMF framework variables are not initialized"
83 if [ -z $PGDATA ]; then
84 echo "Error: postgresql_14/data property not set"
85 exit $SMF_EXIT_ERR_CONFIG
88 if [ -z $PGLOG ]; then
89 echo "Error: postgresql_14/log property not set"
90 exit $SMF_EXIT_ERR_CONFIG
97 $PGBIN/pg_ctl
-D $PGDATA -l $PGDATA/$PGLOG start
101 $PGBIN/pg_ctl
-D $PGDATA -m fast stop
105 $PGBIN/pg_ctl
-D $PGDATA reload
109 echo "Usage: $0 {start|stop|refresh}"