#!/bin/sh
# PostgreSQL boot time script for Slackware, taken from the
# contributed boot-time script for FreeBSD. Please put this in:
# /etc/rc.d/rc.postgresql

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

# Required programs should be in the PATH.
DAEMON=/usr/sbin/pg_ctl
DATADIR=/var/lib/postgresql
LOGDIR=/var/log/postgresql
LOGFILE=${LOGDIR}/postgresql.log

case "$1" in
  start) echo -n "PostgreSQL 8.0.1 ... "
         su postgres -c "${DAEMON} start -D '${DATADIR}' -s -l '${LOGFILE}'" \
            && echo " started." \
            || echo "" ;;

  stop) echo  -n "PostgreSQL 8.0.1 ... "
        su postgres -c "${DAEMON} stop -D '${DATADIR}' -s -m fast"
        echo "" ;;

  restart) echo -n "PostgreSQL 8.0.1 ... "
           su postgres -c "${DAEMON} restart -D '${DATADIR}' -s -m fast"
           echo "" ;;

  status) echo -n "PostgreSQL 8.0.1 ... "
          su postgres -c "${DAEMON} status -D '${DATADIR}'"
          echo "" ;;

  *) echo "Usage: `basename $0` {start|stop|restart|status}" 1>&2
     exit 1
     ;;
esac
