SysV startup script name in binary RPM distribution

From: "Mike Nerone" <mike(at)nerone(dot)org>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: SysV startup script name in binary RPM distribution
Date: 2003-08-11 19:46:01
Message-ID: 003c01c36041$31bd82f0$e75a8ed1@LANGLEY
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I'm not a subscriber to the list. Please copy any responses directly to me.
Thanks.

It's such a minor, but annoying bug, and is easily fixed:

The stock startup script included in the RPM (I currently use the 7.3.3 RPM
for RH7.3), /etc/rc.d/init.d/postgresql, sets the service name (the $NAME
variable within the script) to the basename by which it was called, with
this line:

NAME=`basename $0`

This seems like a logical thing to do, but it causes a problem because the
system calls the script by its various softlinks (such as
"/etc/rc.d/rc3.d/S85postgresql" or "/etc/rc.d/rc1.d/K15postgresql").

The best example of the effect is that during a normal boot into run level
3, the service name gets set to "S85postgresql" instead of the obviously
correct "postgresql." This is reflected both on the console ("Starting
S85postgresql...[Ok]"), and in the /var/lock/subsys/S85postgresql lock file,
for example. Later when doing a "service postgresql restart" or something
similar, the script is supposed to delete that lock file but fails to,
because it *now* thinks its name is just "postgresql." That ridiculous
/var/lock/subsys/S85postgresql file just hangs around perpetually (like a
thorn in my side).

A trivial fix would be either to change the assignment to

NAME=`basename $0 | /bin/sed -e 's/^[SK][0-9][0-9]//'`

and add the sed requirement to the postgresql-server package, or use two
lines, such as

NAME=`basename $0`
NAME=${NAME#[SK][0-9][0-9]}

which I know works with bash, but I'm not sure if it will work with an
old-style Bourne shell. Incidentally, is there any strong reason it doesn't
just standardize and become the following?

NAME=postgresql

Thanks. Please save me the 10 seconds it takes to reimplement this fix every
time I upgrade. :)

Mike Nerone

/* The only secure computer is one that is unplugged from the network -- and
the wall. */

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2003-08-11 22:22:14 Re: [HACKERS] ALTER TABLE table RENAME COLUMN x TO y
Previous Message Tom Lane 2003-08-11 17:23:01 Re: ALTER TABLE table RENAME COLUMN x TO y