#! /bin/sh
#
# identd	Start/Stop RFC 1413 identd server
#
# chkconfig: - 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
WITHOUT_RC_COMPAT=1

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

# Get config.
N_C_S_CONFIG=/etc/sysconfig/network
. $N_C_S_CONFIG

# Check that networking is up.
is_yes "$NETWORKING" || exit 0

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

# Get identd config
IDENTDOPTS="-e"

PIDFILE=/var/run/identd.pid
LOCKFILE=/var/lock/subsys/identd
RETVAL=0


start() {
	msg_starting $"identd daemon"
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --no-announce -- identd $IDENTDOPTS
        RETVAL=$?
	return $RETVAL
}

stop() {
	msg_stopping $"identd daemon"
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --no-announce identd
        RETVAL=$?
	return $RETVAL
}

restart() {
	stop
	sleep 2
	start
}

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

exit $RETVAL
