#! /bin/sh

# chkconfig: - 99 02
# description: pgpool

# Source function library.
. /etc/init.d/functions

# Parse command line parameters.
case $1 in
  start)
    echo -n "Starting pgpool: "$ECHO_C
    RET=`/usr/bin/pgpool 2>&1`
    if [ -z "$RET" ] ; then
        success
    else
        failure
    fi
    echo
    ;;
  stop)
    echo -n "Stopping pgpool: "
    RET=`/usr/bin/pgpool stop 2>&1 | grep ERROR`
    if [ -z "$RET" ]; then
        success
    else
        failure
    fi
    echo
    ;;
  restart|reload)
    $0 stop
    $0 start
    ;;
  status)
    status pgpool
    ;;
  *)
    # Print help
    echo "Usage: $0 {start|stop|status|restart}" 1>&2
    exit 1
    ;;
esac

exit 0
