#!/bin/sh
#
# dictd          Start/Stop the dictd daemon.
#
# chkconfig: 2345 44 55
# description: dictionary daemon
# processname: dictd
# config: /etc/dictd.conf
# pidfile: /var/run/dictd.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

# Source networking configuration.
SourceIfNotEmpty /etc/sysconfig/dictd

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

start()
{
	start_daemon --lockfile "$LOCKFILE" --expect-user dictd -- dictd $EXTRAOPTIONS
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon  --lockfile "$LOCKFILE" --expect-user dictd -- dictd
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

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

exit $RETVAL
