question about /etc/init.d/postgresql in PGDG
In the init script from the PGDG rpms there's this block of code:
PGDATA=/var/lib/pgsql/data
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base/template1" ]
then
echo "Using old-style directory structure"
else
PGDATA=/var/lib/pgsql/data
fi
Is it just me, or is the else extra noise? Just wondering if there's
a reason a config variable is in two places at once.
On Wed, 2009-08-19 at 00:01 -0600, Scott Marlowe wrote:
In the init script from the PGDG rpms there's this block of code:
PGDATA=/var/lib/pgsql/data
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base/template1" ]
then
echo "Using old-style directory structure"
else
PGDATA=/var/lib/pgsql/data
fiIs it just me, or is the else extra noise?
I haven't bothered to remove it (call me lazy). I will remove it in the
upcoming sets. Thanks.
Regards,
--
Devrim GÜNDÜZ, RHCE
Command Prompt - http://www.CommandPrompt.com
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org
Scott Marlowe <scott.marlowe@gmail.com> writes:
In the init script from the PGDG rpms there's this block of code:
PGDATA=/var/lib/pgsql/data
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base/template1" ]
then
echo "Using old-style directory structure"
else
PGDATA=/var/lib/pgsql/data
fi
Is it just me, or is the else extra noise? Just wondering if there's
a reason a config variable is in two places at once.
In the original coding, the first assignment was
PGDATA=/var/lib/pgsql
and thus the if-test did indeed do something useful with setting PGDATA
differently in the two cases. However, there is no reason whatsoever
for this initscript to be prepared to work with postmaster versions that
would be old enough for the if-test to succeed. I took the whole
if-block out of the just-updated Fedora RPMs, and would recommend the
same for PGDG.
regards, tom lane
2009/8/19 Tom Lane <tgl@sss.pgh.pa.us>:
Scott Marlowe <scott.marlowe@gmail.com> writes:
In the init script from the PGDG rpms there's this block of code:
PGDATA=/var/lib/pgsql/data
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base/template1" ]
then
echo "Using old-style directory structure"
else
PGDATA=/var/lib/pgsql/data
fiIs it just me, or is the else extra noise? Just wondering if there's
a reason a config variable is in two places at once.In the original coding, the first assignment was
PGDATA=/var/lib/pgsql
and thus the if-test did indeed do something useful with setting PGDATA
differently in the two cases. However, there is no reason whatsoever
for this initscript to be prepared to work with postmaster versions that
would be old enough for the if-test to succeed. I took the whole
if-block out of the just-updated Fedora RPMs, and would recommend the
same for PGDG.
The only reason I noticed it was that I was building a server with a
separate /data partition for the db to live in, and went to edit
/etc/init.d/postgresql and was faced with two PGDATA assignments... I
too deleted the entire if else block when faced with it.
On Wed, 19 Aug 2009, Scott Marlowe wrote:
The only reason I noticed it was that I was building a server with a
separate /data partition for the db to live in, and went to edit
/etc/init.d/postgresql and was faced with two PGDATA assignments... I
too deleted the entire if else block when faced with it.
You should never edit that script, because then you'll be stuck resolving
conflicts if you upgrade and the packager makes a change to it to fix a
bug or something like that. If you want to relocate PGDATA, you should
change /etc/sysconfig/pgsql/postgresql instead and put your local
customizations there. That file is overlaid on top of the defaults just
after they're set:
# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}
What I do is put *all* the defaults into that file, so that there's no
confusion about which version I'm using.
$ cat /etc/sysconfig/pgsql/postgresql
PGENGINE=/usr/bin
PGPORT=5432
PGDATA=/var/lib/pgsql/data
PGLOG=/var/lib/pgsql/pgstartup.log
The nice side-effect of this is that it makes it easy to set all these
values in a user's login profile, so that you can do things like run
pg_ctl manually instead of using the init scripts as root. Put something
like this in your profile:
. /etc/sysconfig/pgsql/postgresql
export PGDATA PGPORT PGLOG
export PATH="$PGENGINE:$PATH"
And then cycling the engine as the postgres user is as easy as:
pg_ctl start -l $PGLOG
pg_ctl stop
For my login, I add these two bits as well to make that easier, since I
never use the real start/stop commands anyway:
alias start="pg_ctl -D $PGDATA -l $PGLOG -w start && tail $PGLOG"
alias stop="pg_ctl -D $PGDATA stop -m fast"
--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD
On Wed, 2009-08-19 at 12:31 -0400, Tom Lane wrote:
In the original coding, the first assignment was
PGDATA=/var/lib/pgsql
and thus the if-test did indeed do something useful with setting
PGDATA
differently in the two cases. However, there is no reason whatsoever
for this initscript to be prepared to work with postmaster versions
that
would be old enough for the if-test to succeed. I took the whole
if-block out of the just-updated Fedora RPMs, and would recommend the
same for PGDG.
Done. It will appear in next set of releases. Thanks.
Regards,
--
Devrim GÜNDÜZ, RHCE
Command Prompt - http://www.CommandPrompt.com
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org