postgres init script things solved
The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about tchs
and my postgres account defaults to bash. So (thanks to Steve "Stevers!"
Coile) I changed it to bash:
-----------------------------------------------------
if [ ${USE_SYSLOG} = "yes" ]; then
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p
${FACILITY}.notice) &" > /dev/null 2>&1 &
else
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" >
/dev/null 2>&1 &
fi
-----------------------------------------------------
cool, but there was another problem. The script wouldn't stop the postmaster
at halt/reboot while it worked just fine if manually invoked. (RedHat 5.0
sysV init)
Meanwhile I leafed some shell programming book and things cleared up a bit.
In the /etc/rc.d/rc file (the one to start/stop services), the 'stop'
branch, there is a section meant to check if subsystems are up.
-----------------------------------------------------
# Check if the subsystem is already up.
subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
[ ! -f /var/lock/subsys/$subsys ] && \
[ ! -f /var/lock/subsys/${subsys}.init ] && continue
-----------------------------------------------------
That's it, if there's no file named exactly after the symlink (without K??)
in /var/lock/subsys, then it decides the subsystem is not up and gracefully
exits.
If you look in /etc/rc.d/init.d/postgres.init (copy of
postgresql-?.?.?/contrib/linux/postgres.init), you'll find:
-----------------------------------------------------
# touch /var/lock/subsys/${POSTMASTER}
-----------------------------------------------------
which is equally commented and wrong for that kind of init. It should be:
-----------------------------------------------------
# use the name of the symlink without [KS]??
touch /var/lock/subsys/postgres
-----------------------------------------------------
I use:
K05postgres -> /etc/rc.d/init.d/postgres.init on runlevel 1
K05postgres -> /etc/rc.d/init.d/postgres.init on runlevel 6
S98postgres -> /etc/rc.d/init.d/postgres.init on runlevel 3
Claudiu
Attachments:
Applied.
This is a multi-part message in MIME format.
------=_NextPart_000_0087_01BD6217.FE9E50C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bitThe postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about tchs
and my postgres account defaults to bash. So (thanks to Steve "Stevers!"
Coile) I changed it to bash:
-----------------------------------------------------
if [ ${USE_SYSLOG} = "yes" ]; thensu - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p
${FACILITY}.notice) &" > /dev/null 2>&1 &else
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" >
/dev/null 2>&1 &fi
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)
The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about tchs
and my postgres account defaults to bash. So (thanks to Steve "Stevers!"
Coile) I changed it to bash:
OK, but _I_ don't run bash. So someone else is now maintaining this
file? Why didn't we keep both forms in the file, with one commented out?
What are we trying to accomplish here??
- Tom
The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about tchs
and my postgres account defaults to bash. So (thanks to Steve "Stevers!"
Coile) I changed it to bash:OK, but _I_ don't run bash. So someone else is now maintaining this
file? Why didn't we keep both forms in the file, with one commented out?
What are we trying to accomplish here??
bash/sh is the standard, expecially because the top of the file has
#!/bin/sh.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)
On Mon, 27 Apr 1998, Thomas G. Lockhart wrote:
The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about tchs
and my postgres account defaults to bash. So (thanks to Steve "Stevers!"
Coile) I changed it to bash:OK, but _I_ don't run bash. So someone else is now maintaining this
file? Why didn't we keep both forms in the file, with one commented out?
What are we trying to accomplish here??
Why not do what most init scripts do and use the standard /bin/sh?
The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about tchs
and my postgres account defaults to bash. So (thanks to Steve "Stevers!"
Coile) I changed it to bash:OK, but _I_ don't run bash. So someone else is now maintaining this
file? Why didn't we keep both forms in the file, with one commented out?
What are we trying to accomplish here??bash/sh is the standard, expecially because the top of the file has
#!/bin/sh.
Sorry, the top of the init script and the postgres shell aren't related.
The init script is run at startup out of the root account. The line
which was changed is run under the postgres account, which can have a
different shell from the root shell.
imho it is not a step forward to break some code to help others. How
about asking the person submitting the patch to document what they did
differently? The original code at least had a line saying what had to be
changed; the patch doesn't fix the comment or suggest how to support an
alternate shell.
Or, have two files in contrib, postgres.init.tcsh and postgres.init. Or
at least something which is a step forward rather than sideways...
- Tom
about asking the person submitting the patch to document what they did
differently? The original code at least had a line saying what had to be
changed; the patch doesn't fix the comment or suggest how to support an
alternate shell.Or, have two files in contrib, postgres.init.tcsh and postgres.init. Or
at least something which is a step forward rather than sideways...
Ok, now have two files.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)
The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about
tchs
and my postgres account defaults to bash. So (thanks to Steve
"Stevers!"
Coile) I changed it to bash:
OK, but _I_ don't run bash. So someone else is now maintaining this
file? Why didn't we keep both forms in the file, with one commented out?
What are we trying to accomplish here??
Let me explain myself.
The point is I changed script because IT DIDN'T STOP THE POSTMATER.
The original 'touch' line was commented out so there was no way (by means of
sysV) the script would stop gracefully the postmaster. (I don't know what
damage would occur from improper shut down, but I dislike taking chances.)
And even more, just uncommenting the 'touch' line wouldn't make it right
since the sysV expects the 'touched file' to be named after the halt/reboot
script symlink (this also implies keeping the same name on both symlinks).
In the original script it was ${POSTMASTER} which expanded to 'postmaster'
while the sysV (X) editor symlinked it to [KS]??postgres.
About bash, it's the usual shell for regular users. I guess the start/stop
script was meant for users who don't know/cannot write their own.
Claudiu Balciza
Import Notes
Resolved by subject fallback
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing abouttchs
and my postgres account defaults to bash. So (thanks to Steve
"Stevers!"
Coile) I changed it to bash:
...
OK, but _I_ don't run bash. So someone else is now maintaining this
file? Why didn't we keep both forms in the file, with one commented out?
What are we trying to accomplish here??
...
About bash, it's the usual shell for regular users. I guess the start/stop
script was meant for users who don't know/cannot write their own.
Perhaps we should write scripts for just plain old 'sh'. This is available
everywhere (sort of even on SCO).
If not that, bash might be a better choice than tcsh as it is perhaps more
common (we even run it on all our Solaris machines where I work).
-dg
David Gould dg@illustra.com 510.628.3783 or 510.305.9468
Informix Software (No, really) 300 Lakeside Drive Oakland, CA 94612
"(Windows NT) version 5.0 will build on a proven system architecture
and incorporate tens of thousands of bug fixes from version 4.0."
-- <http://www.microsoft.com/y2k.asp?A=7&B=5>
OK, but _I_ don't run bash. So someone else is now maintaining this
file? Why didn't we keep both forms in the file, with one commented out?
What are we trying to accomplish here??...
About bash, it's the usual shell for regular users. I guess the start/stop
script was meant for users who don't know/cannot write their own.Perhaps we should write scripts for just plain old 'sh'. This is available
everywhere (sort of even on SCO).If not that, bash might be a better choice than tcsh as it is perhaps more
common (we even run it on all our Solaris machines where I work).
If you want portability, then plain old Bourne shell should probably be
the shell of choice. Most implementations's on /bin/sh behave the same,
and such scripts will run just fine under bash or ksh.
The same is not true in the csh world...different implementations of
/bin/csh tend to have different bugs (eg some of them have the sense of
|| and && swapped). Tcsh is (I believe) fairly bug free...but much less
widely available than /bin/sh...
Pete.
Import Notes
Reference msg id not found: H0000ccf0a39b1b4@MHS | Resolved by subject fallback