#! /bin/sh
#
# binkd       Binkd FTN tcp/ip lines mailer
#
# chkconfig: 2345 86 14
# description: Binkd - tcp/ip fidonet mailer
# processname: binkd
# config: /etc/ftn/binkd.cfg

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

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

start()
{
	echo -n "Starting Binkd tcp/ip line mailer: "
	daemon --user ftn /usr/sbin/binkd -D -C -s
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	return $RETVAL
}

stop()
{
	echo -n "Stopping Binkd tcp/ip line mailer: "
	killproc binkd && success "stopping Binkd tcp/ip line mailer" || failure "stopping Binkd tcp/ip line mailer"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	return $RETVAL
}

restart()
{
	stop
	start
}

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

exit $RETVAL
