This patch is to add more comments
to postgres.init.sh , clairify the options available, and to add easy support for installation of postgres into the runlevel system. "sh postgres.init.sh install" Will now install "postgres" in the /etc/rc.d/init.d directory and execute /sbin/chkconfig to hook up the symbolic links. An uninstall option is also added. Enclosed is the patch and the patched file Clark
This commit is contained in:
parent
40457dfde9
commit
9e4e33c996
|
@ -1,25 +1,93 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# postgres.init Start postgres back end system.
|
# postgres.init.sh - This script is used to start/stop
|
||||||
|
# the postgreSQL listener process.
|
||||||
#
|
#
|
||||||
# Author: Thomas Lockhart <lockhart@alumni.caltech.edu>
|
# Usage
|
||||||
# modified from other startup files in the RedHat Linux distribution
|
|
||||||
#
|
#
|
||||||
# This version can log backend output through syslog using the local5 facility.
|
# You can use this script manually, and/or you
|
||||||
# To enable this, edit /etc/syslog.conf to include a line similar to:
|
# can install this script into the runlevel system
|
||||||
# local5.* /var/log/postgres
|
# by running "sh postgres.init.sh install"
|
||||||
# and then set USE_SYSLOG to "yes" below
|
#
|
||||||
|
# Credits
|
||||||
|
#
|
||||||
|
# Thomas Lockhart <lockhart@alumni.caltech.edu>
|
||||||
|
# modified from other startup files in the
|
||||||
|
# RedHat Linux distribution
|
||||||
|
#
|
||||||
|
# Clark Evans <cce@clarkevans.com>
|
||||||
|
# cleaned up, added comments, etc.
|
||||||
|
#
|
||||||
|
# RedHat Stuff
|
||||||
|
#
|
||||||
|
# chkconfig: 345 85 15
|
||||||
|
# description: Starts and stops the PostgreSQL backend daemon\
|
||||||
|
# that handles all database requests.
|
||||||
|
# processname: postmaster
|
||||||
|
# pidfile: /var/run/postmaster.pid
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Note
|
||||||
|
#
|
||||||
|
# This version can log backend output through syslog using
|
||||||
|
# the local5 facility. To enable this, set USE_SYSLOG to "yes"
|
||||||
|
# below and then edit /etc/syslog.conf to include a line
|
||||||
|
# similar to:
|
||||||
|
#
|
||||||
|
# local5.* /var/log/postgres
|
||||||
|
#
|
||||||
|
# Config Variables
|
||||||
|
#
|
||||||
|
PGACCOUNT="postgres"
|
||||||
|
#
|
||||||
|
# The non-root user account which will be used to run the
|
||||||
|
# PostgreSQL executeable. For this script to work, the
|
||||||
|
# shell for this account must be SH/BASH.
|
||||||
|
#
|
||||||
|
# The following lines should be in this account's .bash_profile
|
||||||
|
#
|
||||||
|
# PATH=$PATH:$HOME/bin
|
||||||
|
# MANPATH=$MANPATH:/opt/pgsql/man
|
||||||
|
# PGLIB=/opt/pgsql/lib
|
||||||
|
# PGDATA=/opt/pgsql/data
|
||||||
|
#
|
||||||
|
POSTMASTER="postmaster"
|
||||||
|
#
|
||||||
|
# The executable program which is to be run, in this case
|
||||||
|
# it is the listener, which waits for requests on the port
|
||||||
|
# specified during configuration.
|
||||||
|
#
|
||||||
|
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
|
||||||
#
|
#
|
||||||
#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="-B 256"
|
||||||
#PGOPTS="-i -B 256" # -i to enable TCP/IP rather than Unix socket
|
#
|
||||||
|
# The B option sets the number of shared buffers
|
||||||
|
#
|
||||||
|
# Add the "-i" option to enable TCP/IP sockets in addition
|
||||||
|
# to unix domain sockets. This is needed for Java's JDBC
|
||||||
|
#
|
||||||
|
# PGOPTS="-i -B 256"
|
||||||
|
#
|
||||||
|
# Add the -D option if you want to ovverride the PGDATA
|
||||||
|
# environment variable defined in
|
||||||
|
#
|
||||||
|
# PGOPTS="-B 256 -D/opt/pgsql/data
|
||||||
|
#
|
||||||
|
# Add the -p option if you would like the listener to
|
||||||
|
# attach to a port other than the one configured (5432?)
|
||||||
|
#
|
||||||
|
# PGOPTS="-B 256 -D/opt/pgsql_beta/data -p 5433"
|
||||||
|
#
|
||||||
|
|
||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
@ -27,49 +95,68 @@ PGOPTS="-B 256"
|
||||||
# Get config.
|
# Get config.
|
||||||
. /etc/sysconfig/network
|
. /etc/sysconfig/network
|
||||||
|
|
||||||
|
#
|
||||||
# Check that networking is up.
|
# Check that networking is up.
|
||||||
# Pretty much need it for postmaster.
|
# Pretty much need it for postmaster.
|
||||||
|
#
|
||||||
if [ ${NETWORKING} = "no" ]
|
if [ ${NETWORKING} = "no" ]
|
||||||
then
|
then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#[ -f ${PGBIN}/${POSTMASTER} ] || exit 0
|
#[ -f /opt/pgsq//bin/postmaster ] || exit 0
|
||||||
|
|
||||||
|
#
|
||||||
# See how we were called.
|
# See how we were called.
|
||||||
|
#
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ -f ${PGLOGFILE} ]
|
if [ -f ${PGLOGFILE} ]
|
||||||
then
|
then
|
||||||
mv ${PGLOGFILE} ${PGLOGFILE}.old
|
mv ${PGLOGFILE} ${PGLOGFILE}.old
|
||||||
fi
|
fi
|
||||||
echo -n "Starting postgres: "
|
echo -n "Starting postgres: "
|
||||||
# force full login to get path names
|
#
|
||||||
# my postgres runs SH/BASH so use proper syntax in redirection...
|
# force full login to get PGDATA and PGLIB path names
|
||||||
if [ ${USE_SYSLOG} = "yes" ]; then
|
# Since the login script for ${PGACCOUNT} is SH/BASH compliant,
|
||||||
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY}.notice) &" > /dev/null 2>&1 &
|
# we use proper redirection syntax...
|
||||||
else
|
#
|
||||||
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > /dev/null 2>&1 &
|
if [ ${USE_SYSLOG} = "yes" ]; then
|
||||||
fi
|
su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p ${FACILITY}.notice) &" > /dev/null 2>&1 &
|
||||||
sleep 5
|
else
|
||||||
pid=`pidof ${POSTMASTER}`
|
su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" > /dev/null 2>&1 &
|
||||||
echo -n "${POSTMASTER} [$pid]"
|
fi
|
||||||
# touch /var/lock/subsys/${POSTMASTER}
|
sleep 5
|
||||||
echo
|
pid=`pidof ${POSTMASTER}`
|
||||||
;;
|
echo -n "${POSTMASTER} [$pid]"
|
||||||
|
# touch /var/lock/subsys/${POSTMASTER}
|
||||||
|
echo
|
||||||
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping postgres: "
|
echo -n "Stopping postgres: "
|
||||||
pid=`pidof ${POSTMASTER}`
|
pid=`pidof ${POSTMASTER}`
|
||||||
if [ "$pid" != "" ] ; then
|
if [ "$pid" != "" ] ; then
|
||||||
echo -n "${POSTMASTER} [$pid]"
|
echo -n "${POSTMASTER} [$pid]"
|
||||||
kill -TERM $pid
|
kill -TERM $pid
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
|
install)
|
||||||
|
echo "Adding postgres to runlevel system."
|
||||||
|
cp $0 /etc/rc.d/init.d/postgres
|
||||||
|
/sbin/chkconfig --add postgres
|
||||||
|
echo
|
||||||
|
;;
|
||||||
|
uninstall)
|
||||||
|
echo "Deleting postgres from runlevel system."
|
||||||
|
/sbin/chkconfig --del postgres
|
||||||
|
rm /etc/rc.d/init.d/postgres
|
||||||
|
echo
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop}"
|
echo "Usage: $0 {start|stop|install|uninstall}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue