#!/bin/sh
#
# oidentd		This shell script takes care of starting and stopping oidentd.
#
# chkconfig:	2345 80 30
# description:	oidentd is a TCP/IP IDENT protocol server 
#		
# processname:	oidentd
# config:	
# pidfile:

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

# Source networking configuration.
. /etc/sysconfig/network

# Source oident configureation.
if [ -f /etc/sysconfig/oidentd ]; then
	. /etc/sysconfig/oidentd
else
	OIDENT_USER=nobody
	OIDENT_GROUP=proc
fi

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down oidentd
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Start daemons.
	if [ ! -f /var/lock/subsys/oidentd ]; then
		msg_starting oidentd
		daemon oidentd -g $OIDENT_GROUP -u $OIDENT_USER $OIDENT_OPTIONS
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/oidentd
	else
		msg_already_running oidentd
	fi
	;;
  stop)
	# Stop daemons.
	if [ -f /var/lock/subsys/oidentd ]; then
		msg_stopping oidentd
		killproc oidentd
		rm -f /var/lock/subsys/oidentd >/dev/null 2>&1
	else
		msg_not_running oidentd
	fi	
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status oidentd
	exit $?
	;;
#  reload)
#	msg_reloading oidentd
#	killproc oidentd -HUP
#	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
