From 77bc683869b38b300a7192a23668a1d36dd82e9c Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 28 Apr 1998 03:25:33 +0000 Subject: Make Linux startup support sh and csh. --- contrib/linux/postgres.init | 77 ----------------------------------------- contrib/linux/postgres.init.csh | 75 +++++++++++++++++++++++++++++++++++++++ contrib/linux/postgres.init.sh | 75 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 77 deletions(-) delete mode 100755 contrib/linux/postgres.init create mode 100755 contrib/linux/postgres.init.csh create mode 100755 contrib/linux/postgres.init.sh diff --git a/contrib/linux/postgres.init b/contrib/linux/postgres.init deleted file mode 100755 index b47d7a8482f..00000000000 --- a/contrib/linux/postgres.init +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# -# postgres.init Start postgres back end system. -# -# Author: Thomas Lockhart -# modified from other startup files in the RedHat Linux distribution -# -# 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 -# -#PGBIN="/opt/postgres/current/bin" # not used - -PGACCOUNT="postgres" # the postgres account (you called it something else?) -POSTMASTER="postmaster" # this probably won't change - -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="-i -B 2048" - -# Source function library. -. /etc/rc.d/init.d/functions - -# Get config. -. /etc/sysconfig/network - -# Check that networking is up. -# Pretty much need it for postmaster. -if [ ${NETWORKING} = "no" ] -then - exit 0 -fi - -#[ -f ${PGBIN}/${POSTMASTER} ] || exit 0 - -# See how we were called. -case "$1" in - start) - if [ -f ${PGLOGFILE} ] - then - mv ${PGLOGFILE} ${PGLOGFILE}.old - fi - echo -n "Starting postgres: " -# force full login to get path names - 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 - sleep 5 - pid=`pidof ${POSTMASTER}` - echo -n "${POSTMASTER} [$pid]" - sleep 2 -# touch /var/lock/subsys/${POSTMASTER} -# use the name of the symlink - touch /var/lock/subsys/postgres - echo - ;; - stop) - echo -n "Stopping postgres: " - pid=`pidof ${POSTMASTER}` - if [ "$pid" != "" ] ; then - echo -n "${POSTMASTER} [$pid]" - kill -TERM $pid - sleep 3 - fi - echo - ;; - *) - echo "Usage: $0 {start|stop}" - exit 1 -esac - -exit 0 diff --git a/contrib/linux/postgres.init.csh b/contrib/linux/postgres.init.csh new file mode 100755 index 00000000000..ebe9d70c84f --- /dev/null +++ b/contrib/linux/postgres.init.csh @@ -0,0 +1,75 @@ +#!/bin/sh +# +# postgres.init Start postgres back end system. +# +# Author: Thomas Lockhart +# modified from other startup files in the RedHat Linux distribution +# +# 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 +# +#PGBIN="/opt/postgres/current/bin" # not used +PGACCOUNT="postgres" # the postgres account (you called it something else?) +POSTMASTER="postmaster" # this probably won't change + +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 + +# Source function library. +. /etc/rc.d/init.d/functions + +# Get config. +. /etc/sysconfig/network + +# Check that networking is up. +# Pretty much need it for postmaster. +if [ ${NETWORKING} = "no" ] +then + exit 0 +fi + +#[ -f ${PGBIN}/${POSTMASTER} ] || exit 0 + +# See how we were called. +case "$1" in + start) + 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... + 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 + sleep 5 + pid=`pidof ${POSTMASTER}` + echo -n "${POSTMASTER} [$pid]" +# touch /var/lock/subsys/${POSTMASTER} + echo + ;; + stop) + echo -n "Stopping postgres: " + pid=`pidof ${POSTMASTER}` + if [ "$pid" != "" ] ; then + echo -n "${POSTMASTER} [$pid]" + kill -TERM $pid + sleep 1 + fi + echo + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 +esac + +exit 0 diff --git a/contrib/linux/postgres.init.sh b/contrib/linux/postgres.init.sh new file mode 100755 index 00000000000..43da349d27d --- /dev/null +++ b/contrib/linux/postgres.init.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# +# postgres.init Start postgres back end system. +# +# Author: Thomas Lockhart +# modified from other startup files in the RedHat Linux distribution +# +# 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 +# +#PGBIN="/opt/postgres/current/bin" # not used +PGACCOUNT="postgres" # the postgres account (you called it something else?) +POSTMASTER="postmaster" # this probably won't change + +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 + +# Source function library. +. /etc/rc.d/init.d/functions + +# Get config. +. /etc/sysconfig/network + +# Check that networking is up. +# Pretty much need it for postmaster. +if [ ${NETWORKING} = "no" ] +then + exit 0 +fi + +#[ -f ${PGBIN}/${POSTMASTER} ] || exit 0 + +# See how we were called. +case "$1" in + start) + if [ -f ${PGLOGFILE} ] + then + mv ${PGLOGFILE} ${PGLOGFILE}.old + fi + echo -n "Starting postgres: " +# force full login to get path names +# my postgres runs CSH/TCSH so use proper syntax in redirection... + if [ ${USE_SYSLOG} = "yes" ]; then + su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} |& logger -p ${FACILITY}.notice) &" > /dev/null& + else + su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} >>&! ${PGLOGFILE} &" > /dev/null& + fi + sleep 5 + pid=`pidof ${POSTMASTER}` + echo -n "${POSTMASTER} [$pid]" +# touch /var/lock/subsys/${POSTMASTER} + echo + ;; + stop) + echo -n "Stopping postgres: " + pid=`pidof ${POSTMASTER}` + if [ "$pid" != "" ] ; then + echo -n "${POSTMASTER} [$pid]" + kill -TERM $pid + sleep 1 + fi + echo + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 +esac + +exit 0 -- cgit v1.2.3