Your message dated Fri, 29 Jul 2005 08:30:10 +0200
with message-id <[EMAIL PROTECTED]>
and subject line Bug#319492: PostgreSQL init script ignores environment file
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 22 Jul 2005 15:00:23 +0000
>From [EMAIL PROTECTED] Fri Jul 22 08:00:23 2005
Return-path: <[EMAIL PROTECTED]>
Received: from shire.ontko.com [199.164.165.1] 
        by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
        id 1Dvz0h-0000cM-00; Fri, 22 Jul 2005 08:00:23 -0700
Received: from [199.164.165.137] ([EMAIL PROTECTED] [199.164.165.137])
        by shire.ontko.com (8.12.3/8.12.3/Debian-7.1) with ESMTP id 
j6MF0LXu017831
        for <[EMAIL PROTECTED]>; Fri, 22 Jul 2005 10:00:21 -0500
Message-ID: <[EMAIL PROTECTED]>
Date: Fri, 22 Jul 2005 10:00:21 -0500
From: Ryan <[EMAIL PROTECTED]>
User-Agent: Debian Thunderbird 1.0.2 (X11/20050611)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: [EMAIL PROTECTED]
Subject: PostgreSQL init script ignores environment file
Content-Type: multipart/mixed;
 boundary="------------070606090405020603050804"
Delivered-To: [EMAIL PROTECTED]
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
        (1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
        autolearn=no version=2.60-bugs.debian.org_2005_01_02

This is a multi-part message in MIME format.
--------------070606090405020603050804
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Package: postgresql
Version: 7.4.7-6sarge1

The init script for PostgreSQL ignores the environment options in 
/etc/postgresql/postgresql.env.

This is an issue because I want to specify alternate database storage 
locations (in addition to the default).  So I add the following line to 
/etc/postgresql/postgresql.env:

  PGDATA2=/data-ext/postgres

That works fine for the frontend programs, which read 
/etc/postgresql/postgresql.env.  However, the init script has no 
facility for setting environment variables besides editing the init 
script itself.  This is evident when I go to create the database using psql:

  [EMAIL PROTECTED]:~$ createdb -D 'PGDATA2' alpha
  createdb: database creation failed: ERROR:  postmaster environment 
variable "PGDATA2" not found

I propose the following line near the top of the init script:

. /etc/postgresql/postgresql.env

This sources the environment file so the daemon and the frontend 
programs have the same relavent environment variables.

Ryan VanMiddlesworth


--------------070606090405020603050804
Content-Type: text/plain;
 name="postgresql"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="postgresql"

#! /bin/bash
#
# NOTE TO SYSTEM ADMINISTRATORS #
# To stop postgresql running, use the update-rc.d facility, or file-rc
# from the file-rc package.

export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin

PREFIX=/usr/lib/postgresql
POSTMASTER=$PREFIX/bin/postmaster
PG_CTL=$PREFIX/bin/pg_ctl
PG_AUTOVACUUM=$PREFIX/bin/pg_autovacuum
PG_STARTUP=$PREFIX/bin/postgresql-startup
PGPORT=$(grep -si '^port *=' /etc/postgresql/postgresql.conf | cut -f2 -d=)

# Source the environment file
. /etc/postgresql/postgresql.env

# Make sure the log directory and file exist with the correct ownership
assert_logfile() {
    LOGFILE=${POSTGRES_LOG:-/var/log/postgresql/postgres.log}
    LOGDIR="`dirname \"$LOGFILE\"`"

    [ -d "$LOGDIR" ] || install -d -m 2775 -o root -g postgres "$LOGDIR"

    if [ ! -e "$LOGFILE" ]; then
        touch "$LOGFILE"
        chown postgres.postgres "$LOGFILE"
        chmod 640 "$LOGFILE"
    fi
}

# Make sure the socket directory exist with the correct ownership
assert_socketdir() {
    SOCKETDIR=/var/run/postgresql

    if [ ! -d "$SOCKETDIR" ]; then
        if [ ! -d /var/run ]; then
            echo "Error: /var/run does not exist. Aborting." >&2
            exit 1
        fi
        install -d -m 2775 -o postgres -g postgres "$SOCKETDIR"
    fi
}

startup () {
        echo -n " postmaster"
        assert_logfile
        assert_socketdir

        # execute startup checks that require root privileges and cannot be
        # done in postgresql-startup
        /usr/share/postgresql/startup-checks-root.sh

        ERRMSG=$(/sbin/start-stop-daemon --pidfile $PGDATA/postmaster.pid 
--oknodo --chuid postgres --startas $PG_STARTUP --start 2>&1)

        if [ $? != 0 ]; then
            echo "(FAILED)"
            [ "$ERRMSG" ] && echo "ERROR: $ERRMSG" >&2 || true
            exit 1
        fi

        [ "$ERRMSG" ] && echo -n " ($ERRMSG)" >&2 || true

        autovacuum_start
}

stop () {
        autovacuum_stop
        echo -n " postmaster"
        start-stop-daemon -c postgres --start --exec $PG_CTL -- stop -s -w -m 
fast

        # try harder if "fast" mode does not work
        if [ -f "$PGDATA/postmaster.pid" ]; then
            echo -n "(does not shutdown gracefully, now stopping immediately)"
            start-stop-daemon -c postgres --start --exec $PG_CTL -- stop -s -w 
-m immediate
        fi

        # if that still not helps, use the big hammer
        if [ -f "$PGDATA/postmaster.pid" ]; then
            echo -n "(does not shutdown, killing the process)"
            PID=`head -n 1 "$PGDATA/postmaster.pid"`
            if [ "$PID" ]; then
                kill -9 "$PID" || true
                rm -f "$PGDATA/postmaster.pid"
            fi
        fi
}

autovacuum_start() {
        # See if we should start autovacuuming
        if [ -x $PG_AUTOVACUUM ]
        then
            case "$AUTOVACUUM" in yes | Yes | YES | y | Y | on | ON | True | 
true | TRUE | 1)
                OPTS="-D -p ${PGPORT:=5432}"
                if [ -n "$AVAC_DEBUG" ]
                then
                        OPTS="$OPTS -d $AVAC_DEBUG"
                fi
                if [ -n "$AVAC_SLEEP_BASE" ]
                then
                        OPTS="$OPTS -s $AVAC_SLEEP_BASE"
                fi
                if [ -n "$AVAC_SLEEP_SCALE" ]
                then
                        OPTS="$OPTS -S $AVAC_SLEEP_SCALE"
                fi
                if [ -n "$AVAC_VAC_BASE" ]
                then
                        OPTS="$OPTS -v $AVAC_VAC_BASE"
                fi
                if [ -n "$AVAC_VAC_SCALE" ]
                then
                        OPTS="$OPTS -V $AVAC_VAC_SCALE"
                fi
                if [ -n "$AVAC_ANAL_BASE" ]
                then
                        OPTS="$OPTS -a $AVAC_ANAL_BASE"
                fi
                if [ -n "$AVAC_ANAL_SCALE" ]
                then
                        OPTS="$OPTS -A $AVAC_ANAL_SCALE"
                fi
                if [ -z "$AVAC_LOG" ]
                then
                        AVAC_LOG=/var/log/postgresql/autovacuum_log
                fi
                OPTS="$OPTS -L $AVAC_LOG"
                echo -n " autovacuum"
                /sbin/start-stop-daemon --oknodo --chuid postgres --exec 
$PG_AUTOVACUUM --start -- $OPTS
                if [ $? != 0 ]; then
                    echo "(FAILED)"
                    exit 1
                fi
                ;;
            esac
        fi
}

autovacuum_stop() {
        if [ -f $PGDATA/autovacuum.pid ]
        then
                echo -n " autovacuum"
                start-stop-daemon --stop --user postgres --name pg_autovacuum
                rm $PGDATA/autovacuum.pid
        fi
}

if [ ! $EUID -eq 0 ]
then
        echo $0 needs to be run by root.
        exit 1
fi

[ -x $POSTMASTER ] || exit

if [ -r /etc/postgresql/postmaster.conf ]
then
        . /etc/postgresql/postmaster.conf
else
        echo "/etc/postgresql/postmaster.conf is missing; cannot start 
postgresql"
        exit 1
fi
PGDATA=${POSTGRES_DATA:-/var/lib/postgres/data}
export PGDATA

## Use of $PG_CTL to stop the postmaster:
## we use $PG_CTL stop -m fast, which will abort and roll back any current
## transactions.  Don't use -immediate, because it's equivalent to 
## kill -9.  Don't use -smart because it waits for people to disconnect
## and we want to force them off when we are shutting down or else the 
## system itself will do a kill -9 to get rid of us.

case "$1" in
    start)
        echo -n "Starting PostgreSQL database server:"
        startup
        echo "."
        ;;
    stop)
        echo -n "Stopping PostgreSQL database server:"
        stop
        echo "."
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    autovac-restart)
        if [ -f $PGDATA/autovacuum.pid ]
        then
                autovacuum_stop
                echo " stopped"
        else
                echo pg_autovacuum not running
        fi
        autovacuum_start
        echo " started"
        ;;
    autovac-start)
        if [ -f $PGDATA/autovacuum.pid ]
        then
                echo pg_autovacuum is already running
        else
                autovacuum_start
                echo " started"
        fi
        ;;
    autovac-stop)
        if [ -f $PGDATA/autovacuum.pid ]
        then
                autovacuum_stop
                echo " stopped"
        else
                echo pg_autovacuum not running
        fi
        ;;
    force-reload | reload)
        start-stop-daemon -c postgres --start --exec $PG_CTL -- reload -D 
${PGDATA}
        ;;
    status)
        start-stop-daemon -c postgres --start --exec $PG_CTL -- status
        ;;
    *)
        echo "Usage: /etc/init.d/postgresql 
{start|stop|autovac-start|autovac-stop|restart|autovac-restart|reload|force-reload|status}"
        exit 1
        ;;
esac

exit 0


--------------070606090405020603050804--

---------------------------------------
Received: (at 319492-done) by bugs.debian.org; 29 Jul 2005 06:30:41 +0000
>From [EMAIL PROTECTED] Thu Jul 28 23:30:41 2005
Return-path: <[EMAIL PROTECTED]>
Received: from box79162.elkhouse.de [213.9.79.162] 
        by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
        id 1DyOOG-0007p7-00; Thu, 28 Jul 2005 23:30:41 -0700
Received: by box79162.elkhouse.de (Postfix, from userid 1000)
        id 3B76216BBB4; Fri, 29 Jul 2005 08:30:10 +0200 (CEST)
Date: Fri, 29 Jul 2005 08:30:10 +0200
From: Martin Pitt <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Bug#319492: PostgreSQL init script ignores environment file
Message-ID: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
        protocol="application/pgp-signature"; boundary="hYooF8G/hrfVAmum"
Content-Disposition: inline
In-Reply-To: <[EMAIL PROTECTED]>
User-Agent: Mutt/1.5.9i
Delivered-To: [EMAIL PROTECTED]
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
        (1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-11.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER,
        HAS_PACKAGE autolearn=ham version=2.60-bugs.debian.org_2005_01_02


--hYooF8G/hrfVAmum
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Package: 7.5.1

Hi Ryan!

Ryan [2005-07-22 10:00 -0500]:
> This is an issue because I want to specify alternate database storage=20
> locations (in addition to the default).  So I add the following line to=
=20
> /etc/postgresql/postgresql.env:
>=20
>  PGDATA2=3D/data-ext/postgres

This is solved much more elegantly in the multi-version/multi-cluster
PostgreSQL infastructure which is now in unstable and will be shipped
in Etch.

Marking as fixed in Sid.

Thanks,

Martin
--=20
Martin Pitt              http://www.piware.de
Ubuntu Developer   http://www.ubuntulinux.org
Debian Developer        http://www.debian.org

--hYooF8G/hrfVAmum
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC6czyDecnbV4Fd/IRAlTBAJ0dQLy1UnXZY2kXbRfepY2sZdhTWwCg00BO
SRkLeRRIlpJLVyCrRWJMbVQ=
=CJM3
-----END PGP SIGNATURE-----

--hYooF8G/hrfVAmum--


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to