From b81b97324fb0fd50f5a9e29c974c25744a7f1e2d Mon Sep 17 00:00:00 2001 From: Adis Nezirovic Date: Sat, 26 Oct 2013 00:40:32 -0500 Subject: system/postgresql: Updated for version 9.3.0. Signed-off-by: Robby Workman --- system/postgresql/rc.postgresql.new | 41 ++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'system/postgresql/rc.postgresql.new') diff --git a/system/postgresql/rc.postgresql.new b/system/postgresql/rc.postgresql.new index 6ccda6a3355e..7e984c658205 100644 --- a/system/postgresql/rc.postgresql.new +++ b/system/postgresql/rc.postgresql.new @@ -1,8 +1,9 @@ #!/bin/bash -# PostgreSQL startup script for Slackware Linux -# Copyright 2007 Adis Nezirovic -# Licensed under GNU GPL v2 +## PostgreSQL startup script for Slackware Linux +## +## Copyright (c) 2007-2013 Adis Nezirovic +## Licensed under GNU GPL v2 # Do not source this script (since it contains exit() calls) @@ -10,12 +11,32 @@ # database files in /var/lib/pgsql. The following should do # the trick. # -# $ su postgres -c "initdb -D /var/lib/pgsql/data" +# $ su postgres -c "initdb -D /var/lib/pgsql/@PG_VERSION@/data" # -LOGFILE=/var/log/postgresql -DATADIR=/var/lib/pgsql/data -POSTGRES=/usr/bin/postgres +# Since PostgreSQL 9.3 this startup script can run multiple PostgreSQL +# versions on different ports and with different data dirs. +# +# e.g. PG_VERSION=9.4 PG_PORT=6432 /etc/rc.d/rc.postgresql start +# +# Older PostgreSQL 9.x versions are supported too, just use PG_VERSION=9.2 + +PG_VERSION=${PG_VERSION:-@PG_VERSION@} +PG_PORT=${PG_PORT:-@PG_PORT@} +LIBDIRSUFFIX="@LIBDIRSUFFIX@" + +if [ "x$PG_VERSION" != "x9.2" ];then + LOGFILE=/var/log/postgresql-$PG_VERSION + DATADIR=/var/lib/pgsql/$PG_VERSION/data + POSTGRES=/usr/lib${LIBDIRSUFFIX}/postgresql/$PG_VERSION/bin/postgres + PG_CTL=/usr/lib${LIBDIRSUFFIX}/postgresql/$PG_VERSION/bin/pg_ctl +else + LOGFILE=/var/log/postgresql + DATADIR=/var/lib/pgsql/data + POSTGRES=/usr/bin/postgres + PG_CTL=/usr/bin/pg_ctl +fi + PIDFILE=postmaster.pid # oom-killer score @@ -38,7 +59,7 @@ OOM_SCORE_ADJ=-1000 pg_ctl() { - CMD="/usr/bin/pg_ctl $@" + CMD="$PG_CTL -o '-p $PG_PORT' $@" su - postgres -c "$CMD" } @@ -71,8 +92,8 @@ case "$1" in else # remove old socket, if it exists and no daemon is running. if [ ! -f $DATADIR/$PIDFILE ]; then - rm -f /tmp/.s.PGSQL.5432 - rm -f /tmp/.s.PGSQL.5432.lock + rm -f /tmp/.s.PGSQL.$PG_PORT + rm -f /tmp/.s.PGSQL.$PG_PORT.lock test x"$OOM_SCORE_ADJ" != x && echo "$OOM_SCORE_ADJ" > /proc/self/oom_score_adj pg_ctl start -w -l $LOGFILE -D $DATADIR exit 0 -- cgit v1.2.3