#!/bin/sh
#
# Startup script for Perlbal load-balancer
#
# chkconfig: - 85 15
#
# description: Perlbal is a reverse proxy and load-balancer
# processname: perlbal
# config: /etc/perlbal/perlbal.conf
# pidfile: /var/run/perlbal.pid
#
WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/run/perlbal.pid
LOCKFILE=/var/lock/subsys/perlbal
RETVAL=0

start() {
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --name perlbal -- perlbal --daemon
	RETVAL=$?
	return $RETVAL
}

stop() {
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --name perlbal -- perlbal
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload|restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status --pidfile "$PIDFILE" --name perlbal -- perlbal
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
