diff options
Diffstat (limited to 'dev-db/postgresql-server/files/postgresql.init-7.4')
-rw-r--r-- | dev-db/postgresql-server/files/postgresql.init-7.4 | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/dev-db/postgresql-server/files/postgresql.init-7.4 b/dev-db/postgresql-server/files/postgresql.init-7.4 index b5ec7093069f..51e0b03deced 100644 --- a/dev-db/postgresql-server/files/postgresql.init-7.4 +++ b/dev-db/postgresql-server/files/postgresql.init-7.4 @@ -1,7 +1,7 @@ #!/sbin/runscript # Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/files/postgresql.init-7.4,v 1.2 2008/04/19 20:37:13 dev-zero Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/files/postgresql.init-7.4,v 1.3 2008/05/13 07:00:36 dev-zero Exp $ opts="${opts} reload" @@ -25,19 +25,32 @@ checkconfig() { start() { checkconfig || return 1 - local retval - ebegin "Starting PostgreSQL" if [ -f "$PGDATA/postmaster.pid" ] ; then rm -f "$PGDATA/postmaster.pid" fi + local retval + su -l ${PGUSER} \ - -c "env PGDATA=\"${PGDATA}\" /usr/lib/postgresql-7.4/bin/pg_ctl start -w -o '--silent-mode=true ${PGOPTS}'" + -c "env PGDATA=\"${PGDATA}\" PATH=\"/usr/lib/postgresql-7.4/bin:${PATH}\" /usr/lib/postgresql-7.4/bin/pg_ctl start -w -o '--silent-mode=true ${PGOPTS}'" retval=$? - echo $retval - eend $retval + [ $retval -ne 0 ] && eend $retval && return $retval + + # The following is to catch the case of an already running server + # in which pg_ctl doesn't know to which server it connected to and false reports the server as 'up' + sleep 2 + if [ ! -f "$PGDATA/postmaster.pid" ] ; then + eerror "The pid-file doesn't exist but pg_ctl reported a running server." + eerror "Please check whether there is another server running on the same port or read the log-file." + eend 1 + return 1 + fi + + local pid=$(grep "^[0-9]\+" "$PGDATA/postmaster.pid") + ps -p "${pid}" &> /dev/null + eend $? } stop() { |