[csw-devel] SF.net SVN: gar:[16374] csw/mgar/pkg/postgresql/branches/postgresql-8. 3-raos/files/CSWpostgresql-server.postinstall.tmpl

guengel at users.sourceforge.net guengel at users.sourceforge.net
Sun Dec 4 21:42:28 CET 2011


Revision: 16374
          http://gar.svn.sourceforge.net/gar/?rev=16374&view=rev
Author:   guengel
Date:     2011-12-04 20:42:28 +0000 (Sun, 04 Dec 2011)
Log Message:
-----------
postgresql/branches/postgresql-8.3-raos: Added USERCONF variable. Changed some names due to recipe changes. When using SMF, sleep for 4 secs before clearing and enabling server in order to prevent it going to maintenance immediately.

Added Paths:
-----------
    csw/mgar/pkg/postgresql/branches/postgresql-8.3-raos/files/CSWpostgresql-server.postinstall.tmpl

Copied: csw/mgar/pkg/postgresql/branches/postgresql-8.3-raos/files/CSWpostgresql-server.postinstall.tmpl (from rev 16347, csw/mgar/pkg/postgresql/branches/postgresql-8.3-raos/files/CSWpostgresql-83.postinstall)
===================================================================
--- csw/mgar/pkg/postgresql/branches/postgresql-8.3-raos/files/CSWpostgresql-server.postinstall.tmpl	                        (rev 0)
+++ csw/mgar/pkg/postgresql/branches/postgresql-8.3-raos/files/CSWpostgresql-server.postinstall.tmpl	2011-12-04 20:42:28 UTC (rev 16374)
@@ -0,0 +1,44 @@
+#!/bin/sh
+# vim:set ft=sh:
+#
+# $Id$
+#
+# Initialize the database cluster if it hasn't been initialized before.
+
+USERCONF=@CSWPGSQLCONFFILE_VERSIONED@
+PGCTL=@bindir@/pg_ctl- at BASE_VERSION_NODOT@
+PGINIT=@bindir@/initdb- at BASE_VERSION_NODOT@
+
+# Read in the user configuration file
+[ -s /opt/csw/etc/${USERCONF} ] && . /opt/csw/etc/${USERCONF}
+[ -s @sysconfdir@/${USERCONF} ] && . @sysconfdir@/${USERCONF}
+
+initialize_cluster() {
+	chown postgres "${PGDATA}"
+	chmod 0700 "${PGDATA}"
+	echo "Initializing PostgreSQL database..."
+	su postgres -c "\"${PGINIT}\" -D \"${PGDATA}\" -E UTF8"
+}
+
+if [ `ls -l ${PGDATA} 2>/dev/null | wc -l` -eq 1 ]; then
+	initialize_cluster
+else
+	echo "The database cluster seems to be initialized already."
+fi
+
+# FIXME: We assume that every Sol 10 user is using SMF, whereas it is possible
+# to use CSW on Sol 10 without SMF
+if [ -x /usr/sbin/svcadm ]; then
+	fmri="cswpostgresql- at BASE_VERSION_NODOT@"
+	echo "Enabling the ${fmri} service in SMF"
+	# Let things settle a little bit
+	sleep 4
+	svcadm clear "${fmri}"
+	svcadm enable "${fmri}"
+else
+	initscript="/etc/opt/csw/init.d/cswpostgresql- at BASE_VERSION_NODOT@"
+	echo "Issuing ${initscript} start"
+	"${initscript}" start
+fi
+
+exit 0

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list