#! /bin/sh
# $Id: identd.init,v 1.1 2004/02/26 17:54:30 thias Exp $
#
# identd	Start/Stop RFC 1413 identd server
#
# chkconfig: 345 35 65
# description:	The identd server provides a means to determine the identity \
#		of a user of a particular TCP connection.  Given a TCP port \
#		number pair, it returns a character string which identifies \
#		the owner of that connection on the server's system.
# processname: identd
# pidfile: /var/run/identd.pid
# config: /etc/identd.conf

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

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi

[ -x /usr/sbin/oidentd ] || exit 0

IDENTDOPTS="-q -u nobody -g nobody"
RETVAL=0

start() {
	echo -n "Starting identd: "
	daemon /usr/sbin/oidentd $IDENTDOPTS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/identd
	return $RETVAL
}

stop() {
	echo -n "Stopping identd services: "
	killproc oidentd
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/identd
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status oidentd
	;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/identd ]; then
	    stop
	    start
	fi
	;;
  *)
	echo "Usage: identd {start|stop|status|restart|reload|condrestart}"
	exit 1
esac

exit $RETVAL
