From 467b613638a0208cfbaaab5d54e07431255408fa Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Mon, 11 Nov 2013 14:59:55 -0600 Subject: postgresql: Fix init to work with postgresql in a drbd data container When postgresql installed on the target and configured with drbd the data will live in the drbd container and the startup script must account for the different invocation to pg_ctl, as well as checking that the config files are properly linked into to the postgresql data directory. The set -e was removed because the script was exiting improperly during the restart operation and status operations. Signed-off-by: Jason Wessel --- .../recipes-support/postgresql/postgresql/postgresql | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'meta-openstack/recipes-support/postgresql') diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql b/meta-openstack/recipes-support/postgresql/postgresql/postgresql index a6b302b..74f7e2d 100644 --- a/meta-openstack/recipes-support/postgresql/postgresql/postgresql +++ b/meta-openstack/recipes-support/postgresql/postgresql/postgresql @@ -1,5 +1,4 @@ #!/bin/sh -set -e ### BEGIN INIT INFO # Provides: postgresql @@ -15,6 +14,19 @@ set -e DAEMON=/usr/bin/postmaster DESC="PostgreSQL RDBMS server" +datadir=`grep ^data_directory /etc/postgresql/postgresql.conf |sed -e "s#^.*= '##; s#'.*##"` +if [ "$datadir" = "" ] ; then + datadir=/etc/postgresql +else + if [ ! -e $datadir/postgresql.conf ] ; then + if [ -e /etc/postgresql/postgresql.conf -a -e $datadir ] ; then + ln -s /etc/postgresql/*.conf $datadir/ + fi + fi +fi + +cd / + start () { echo -n "Starting postgres server..." @@ -24,7 +36,7 @@ start () fi touch /var/log/postgresql.log chown postgres /var/log/postgresql.log - sudo -u postgres /usr/bin/pg_ctl start -w -D /etc/postgresql -s -l /var/log/postgresql.log + sudo -u postgres /usr/bin/pg_ctl start -w -D $datadir -s -l /var/log/postgresql.log if [ $? -eq 0 ]; then echo "done." else @@ -39,7 +51,7 @@ stop () echo "not running." exit 0 fi - sudo -u postgres /usr/bin/pg_ctl stop -w -D /etc/postgresql -m fast -s + sudo -u postgres /usr/bin/pg_ctl stop -w -D $datadir -m fast -s if [ $? -eq 0 ]; then echo "done." else -- cgit v1.2.3-54-g00ecf