]> granicus.if.org Git - postgresql/commitdiff
csh and sh examples were reversed.
authorThomas G. Lockhart <lockhart@fourpalms.org>
Wed, 25 Nov 1998 02:57:27 +0000 (02:57 +0000)
committerThomas G. Lockhart <lockhart@fourpalms.org>
Wed, 25 Nov 1998 02:57:27 +0000 (02:57 +0000)
Update the csh example with new comments and fixes from Thomas' linux box.

contrib/linux/postgres.init.csh
contrib/linux/postgres.init.sh

index ebe9d70c84f854cd2dd988350dc3bea04101c17a..acd1c2a4ede7c62f1ed70bc02415bc0ba0f23ce8 100755 (executable)
@@ -8,18 +8,23 @@
 # This version can log backend output through syslog using the local5 facility.
 # To enable this, edit /etc/syslog.conf to include a line similar to:
 #   local5.*  /var/log/postgres
-# and then set USE_SYSLOG to "yes" below
+# and then set USE_SYSLOG to "yes" and FACILITY to "local5" below
 #
-#PGBIN="/opt/postgres/current/bin"     # not used
+#PGBIN="/opt/postgres/current/bin"     # not used any more - thomas 1997-12-14
 PGACCOUNT="postgres"           # the postgres account (you called it something else?)
 POSTMASTER="postmaster"                # this probably won't change
 
+USE_SOCKET="yes"               # "no" to disable Unix sockets on localhost
+PGSOCKETFILE="/tmp/.s.PGSQL.5432"
 USE_SYSLOG="yes"               # "yes" to enable syslog, "no" to go to /tmp/postgres.log
 FACILITY="local5"              # can assign local0-local7 as the facility for logging
 PGLOGFILE="/tmp/postgres.log"  # only used if syslog is disabled
 
-PGOPTS="-B 256"
-#PGOPTS="-i -B 256"    # -i to enable TCP/IP rather than Unix socket
+PGOPTS="-i -B 1024" #  -S -o '-Fe'"
+if [ ${USE_SOCKET} = "no" ]
+then
+       PGOPTS="-i ${PGOPTS}"   # -i to enable TCP/IP rather than Unix socket
+fi
 
 # Source function library.
 . /etc/rc.d/init.d/functions
@@ -34,22 +39,29 @@ then
        exit 0
 fi
 
+# Don't bother checking for file existance to avoid hardcoding any paths - thomas 1997-12-14
 #[ -f ${PGBIN}/${POSTMASTER} ] || exit 0
 
 # See how we were called.
 case "$1" in
   start)
+# force a stop to kill a running postmaster and to clean up sockets
+# necessary if system crashed (a power outage provoked this feature)
+       eval $0 stop
+# save the old log file, if any
        if [ -f ${PGLOGFILE} ]
        then
                mv ${PGLOGFILE} ${PGLOGFILE}.old
        fi
+
        echo -n "Starting postgres: "
+
 # force full login to get path names
-# my postgres runs SH/BASH so use proper syntax in redirection...
+# my postgres runs tcsh so use proper syntax in redirection...
        if [ ${USE_SYSLOG} = "yes" ]; then
-               su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY}.notice) &" > /dev/null 2>&1 &
+               su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} |& logger -p ${FACILITY}.notice) &" > /dev/null&
        else
-               su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > /dev/null 2>&1 &
+               su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} >>&! ${PGLOGFILE} &" > /dev/null&
        fi
        sleep 5
        pid=`pidof ${POSTMASTER}`
@@ -65,6 +77,10 @@ case "$1" in
                kill -TERM $pid
                sleep 1
        fi
+       if [ ${USE_SOCKET} = "yes" ] && [ -S ${PGSOCKETFILE} ]; then
+               echo -n " (remove socket ${PGSOCKETFILE})"
+               rm -f ${PGSOCKETFILE}
+       fi
        echo
        ;;
   *)
index 43da349d27d738fffc08fa4faeccd0e51d1fd934..ebe9d70c84f854cd2dd988350dc3bea04101c17a 100755 (executable)
@@ -45,11 +45,11 @@ case "$1" in
        fi
        echo -n "Starting postgres: "
 # force full login to get path names
-# my postgres runs CSH/TCSH so use proper syntax in redirection...
+# my postgres runs SH/BASH so use proper syntax in redirection...
        if [ ${USE_SYSLOG} = "yes" ]; then
-               su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} |& logger -p ${FACILITY}.notice) &" > /dev/null&
+               su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY}.notice) &" > /dev/null 2>&1 &
        else
-               su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} >>&! ${PGLOGFILE} &" > /dev/null&
+               su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > /dev/null 2>&1 &
        fi
        sleep 5
        pid=`pidof ${POSTMASTER}`