Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4d71880

Browse files
author
Thomas G. Lockhart
committed
csh and sh examples were reversed.
Update the csh example with new comments and fixes from Thomas' linux box.
1 parent 59d9fd9 commit 4d71880

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

contrib/linux/postgres.init.csh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,23 @@
88
# This version can log backend output through syslog using the local5 facility.
99
# To enable this, edit /etc/syslog.conf to include a line similar to:
1010
# local5.* /var/log/postgres
11-
# and then set USE_SYSLOG to "yes" below
11+
# and then set USE_SYSLOG to "yes" and FACILITY to "local5" below
1212
#
13-
#PGBIN="/opt/postgres/current/bin" # not used
13+
#PGBIN="/opt/postgres/current/bin" # not used any more - thomas 1997-12-14
1414
PGACCOUNT="postgres" # the postgres account (you called it something else?)
1515
POSTMASTER="postmaster" # this probably won't change
1616

17+
USE_SOCKET="yes" # "no" to disable Unix sockets on localhost
18+
PGSOCKETFILE="/tmp/.s.PGSQL.5432"
1719
USE_SYSLOG="yes" # "yes" to enable syslog, "no" to go to /tmp/postgres.log
1820
FACILITY="local5" # can assign local0-local7 as the facility for logging
1921
PGLOGFILE="/tmp/postgres.log" # only used if syslog is disabled
2022

21-
PGOPTS="-B 256"
22-
#PGOPTS="-i -B 256" # -i to enable TCP/IP rather than Unix socket
23+
PGOPTS="-i -B 1024" # -S -o '-Fe'"
24+
if [ ${USE_SOCKET} = "no" ]
25+
then
26+
PGOPTS="-i ${PGOPTS}" # -i to enable TCP/IP rather than Unix socket
27+
fi
2328

2429
# Source function library.
2530
. /etc/rc.d/init.d/functions
@@ -34,22 +39,29 @@ then
3439
exit 0
3540
fi
3641

42+
# Don't bother checking for file existance to avoid hardcoding any paths - thomas 1997-12-14
3743
#[ -f ${PGBIN}/${POSTMASTER} ] || exit 0
3844

3945
# See how we were called.
4046
case "$1" in
4147
start)
48+
# force a stop to kill a running postmaster and to clean up sockets
49+
# necessary if system crashed (a power outage provoked this feature)
50+
eval $0 stop
51+
# save the old log file, if any
4252
if [ -f ${PGLOGFILE} ]
4353
then
4454
mv ${PGLOGFILE} ${PGLOGFILE}.old
4555
fi
56+
4657
echo -n "Starting postgres: "
58+
4759
# force full login to get path names
48-
# my postgres runs SH/BASH so use proper syntax in redirection...
60+
# my postgres runs tcsh so use proper syntax in redirection...
4961
if [ ${USE_SYSLOG} = "yes" ]; then
50-
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY}.notice) &" > /dev/null 2>&1 &
62+
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} |& logger -p ${FACILITY}.notice) &" > /dev/null&
5163
else
52-
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > /dev/null 2>&1 &
64+
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} >>&! ${PGLOGFILE} &" > /dev/null&
5365
fi
5466
sleep 5
5567
pid=`pidof ${POSTMASTER}`
@@ -65,6 +77,10 @@ case "$1" in
6577
kill -TERM $pid
6678
sleep 1
6779
fi
80+
if [ ${USE_SOCKET} = "yes" ] && [ -S ${PGSOCKETFILE} ]; then
81+
echo -n " (remove socket ${PGSOCKETFILE})"
82+
rm -f ${PGSOCKETFILE}
83+
fi
6884
echo
6985
;;
7086
*)

contrib/linux/postgres.init.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ case "$1" in
4545
fi
4646
echo -n "Starting postgres: "
4747
# force full login to get path names
48-
# my postgres runs CSH/TCSH so use proper syntax in redirection...
48+
# my postgres runs SH/BASH so use proper syntax in redirection...
4949
if [ ${USE_SYSLOG} = "yes" ]; then
50-
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} |& logger -p ${FACILITY}.notice) &" > /dev/null&
50+
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY}.notice) &" > /dev/null 2>&1 &
5151
else
52-
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} >>&! ${PGLOGFILE} &" > /dev/null&
52+
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > /dev/null 2>&1 &
5353
fi
5454
sleep 5
5555
pid=`pidof ${POSTMASTER}`

0 commit comments

Comments
 (0)