#! /bin/sh
#
# ftn          Start/Stop FTN services.
#
# chkconfig: 2345 86 14
# description: qico mailer
# processname: qico
# config: /etc/ftn/qico.conf

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

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

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

stop()
{
	action "Stopping qico mailer: " qctl -q
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	action "Reloading qico configuration: " qctl -R
	RETVAL=$?
	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 qico
		RETVAL=$?
		;;
	*)
		echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
