#! /bin/sh
#
# bforce       BinkleyForce FTN mailer
#
# chkconfig: 2345 86 14
# description: BinkleyForce FTN mailer
# processname: bforce
# config: /etc/ftn/bforce.conf

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

LOCKFILE=/var/lock/subsys/bforce
RETVAL=0

start()
{
	echo -n "Starting BinkleyForce mailer: "
	daemon --user ftn /usr/sbin/bforce -d
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	return $RETVAL
}

stop()
{
	echo -n "Stopping BinkleyForce mailer: "
	killproc bforce && success "stopping BinkleyForce mailer" || failure "stopping BinkleyForce mailer"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	echo -n "Reloading BinkleyForce configuration: "
	killproc bforce -HUP && success "reloading BinkleyForce configuration" || failure "reloading BinkleyForce configuration"
	RETVAL=$?
	echo
	return $RETVAL
} 

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

exit $RETVAL
