#!/bin/sh
#
# pound	
#
# chkconfig:	345 85 15
# description:	reverse-proxy and load-balancer
#

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

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/pound ] && . /etc/sysconfig/pound

# Check that networking is up.
if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network ]; then
                # nls "ERROR: Networking is down. %s can't be run." pound
                msg_network_down pound
                exit 1
        fi
else
        exit 0
fi

# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
        if [ ! -f /var/lock/subsys/pound ]; then
		msg_starting pound
        	daemon pound -f /etc/pound/pound.cfg
		RETVAL=$?
    		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pound
	else
        	msg_Already_Running pound
	        exit 1
	fi
	;;
  stop)
        # Stop daemons.
	if [ -f /var/lock/subsys/pound ]; then
                msg_stopping pound
                killproc pound
                rm -f /var/lock/subsys/pound > /dev/null 2>&1
        else
		msg_Not_Running pound
	        exit 1
	fi
	;;
  status)
	status pound
	RETVAL=$?
	exit $RETVAL
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  *)
	msg_Usage "$0 {start|stop|restart|status}"
	exit 1
	;;
esac

exit $RETVAL

