On Tue, 6 Feb 2001, Bruce Momjian wrote:

> > > DAEMON=/home/postgres/bin/pg_ctl
> > 
> >     Ooops.... That is my mistake... Should have been
> > /usr/local/pgsql/bin/pg_ctl. I have /usr/local/pgsql/ symlinked to /home
> > (where there is more, faster disk space). I can submit a patch, or can
> > some one just fix it?
> 
> Change made.

        Actually I found a few more places where I used /home/postgres
instead of /usr/local/pgsql. To make things clear (and for reasons
below) I have attached a new version of the file.

> > > su - postgres sh -c "$DAEMON stop >& /dev/null"
> > 
> >     Hmm... What is wrong here, besides the '>&'? The '>&' can be
> > replaced with '2>&1 >' if that is more standard.
> > 
> Change made.

        Turns out that it has to be '> {dest} 2>&1' for it to work, at
least with bash. So, to reduce confusion on fixes to this file, as I
stated above, a new version is attached. It is tested to work and I don't
see any thing more that is non-standard. Though if you still see problems,
feel free to point them out. :) Thanks and TTYL.

---------------------------------------------------------------------------
|   "For to me to live is Christ, and to die is gain."                    |
|                                            --- Philippians 1:21 (KJV)   |
---------------------------------------------------------------------------
|   Ryan Kirkpatrick  |  Boulder, Colorado  |  http://www.rkirkpat.net/   |
---------------------------------------------------------------------------
#! /bin/sh
#
# PostgreSQL    Start, stop, and get status on the PostgreSQL RDMBS.    
#               This script is Linux distribution independent 
#                 (or at least should be :).
# 
# By Ryan Kirkpatrick <[EMAIL PROTECTED]>.
#
# If you find any problems with this script, or have suggestions
# please send them to me.

# Arguements for pg_ctl and then for the postmaster. Change as needed.
ARGS="-w -D /usr/local/pgsql/data"
PM_ARGS="-i -F"

# Changes should not be needed beyond this point.

# The path that is to be used for the script.
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# What to use to start up the postmster, and a few names.
DAEMON=/usr/local/pgsql/bin/pg_ctl
NAME=postmaster
FILE=postgresql
DESC="PostgreSQL RDBMS"

# Who to run pg_ctl as, should be postgres.
USER="postgres:postgres"

# Where to keep a log file.
LOG="/usr/local/pgsql/server.log"

# Only start if we can find pg_ctl.
test -f $DAEMON || exit 0
set -e

# Parse command line parameters.
case "$1" in
  start)
        # Start the postmaster using pg_ctl and given options.
        echo -n "Starting $DESC: "
        su - postgres sh -c "$DAEMON start $ARGS -o \"$PM_ARGS\" > $LOG 2>&1"
        echo "$NAME."
        ;;
  stop)
        # Stop the postmaster using pg_ctl.
        echo -n "Stopping $DESC: "
        su - postgres sh -c "$DAEMON stop > /dev/null 2>&1" 
        echo "$NAME."
        ;;
  restart)
        # Restart the postmaster by calling ourselves.
        /etc/init.d/$FILE stop
        sleep 5
        /etc/init.d/$FILE start
        ;;
  status)
        # Print the status of the postmaster.
        su - postgres $DAEMON status
        ;;
  *)
        # Print help.
        N=/etc/init.d/$FILE
        echo "Usage: $N {start|stop|restart|status}" >&2
        exit 1
        ;;
esac

exit 0

Reply via email to