#!/bin/sh
#
# postgres - This script is used to start/stop
# the postgreSQL listener process.
#
# Usage
#
# You can use this script manually, and/or you
# can install this script into the runlevel system
# by running "sh postgres.init.sh install"
#
# Credits
#
# Thomas Lockhart # modified from other startup files in the
# RedHat Linux distribution
#
# Clark Evans # cleaned up, added comments, etc.
#
# modified for PostgreSQL book written by Tatsuo Ishii
#
# RedHat Stuff
#
# chkconfig: 345 85 15
# description: Starts and stops the PostgreSQL backend daemon\
# that handles all database requests.
# processname: postmaster
#
# 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.
#
PGDATA="/usr/local/pgsql/data"
POSTMASTER="/usr/local/pgsql/bin/postmaster"
PG_CTL="/usr/local/pgsql/bin/pg_ctl"
#
# 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.
#
# Source function library.
. /etc/rc.d/init.d/functions
#
# See how we were called.
#
case "$1" in
start)
echo -n "Starting postgres: "
su - $PGACCOUNT -c "$POSTMASTER -D $PGDATA"
echo
touch /var/lock/subsys/postgres
;;
stop)
echo -n "Stopping postgres: "
$PG_CTL -m f -D $PGDATA stop
echo
rm -f /var/lock/subsys/postgres
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
|