#!/bin/sh
#
# Start/stops the oident daemon.
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin
OIDENTD=/usr/sbin/oidentd

# See if the daemons are there
test -f ${OIDENTD} || exit 0

# oidentd configuration
OIDENT_OPTIONS=""
OIDENT_USER="nobody"
OIDENT_GROUP="nogroup"
test -f /etc/default/oidentd && . /etc/default/oidentd
# remove obsolete options, these have to be moved to oidentd.conf
# run 'oidentdconfig --show' to see how to do that
OIDENT_OPTIONS=`echo "$OIDENT_OPTIONS"|
	sed -e 's/-[isSnNrwW]//g' -e 's/-F/-f/' -e 's/-x/-r/'`

OPTIONS="${OIDENT_OPTIONS} -u ${OIDENT_USER} -g ${OIDENT_GROUP}"

case "$1" in
	start)
		echo -n "Starting ident daemon:"
		echo -n " oidentd"
		start-stop-daemon --start --quiet --exec ${OIDENTD} -- ${OPTIONS}
		echo "."
		;;
	stop)
		echo -n "Stopping ident daemon:"
		echo -n " oidentd"
		start-stop-daemon --stop --quiet --exec ${OIDENTD} -- ${OPTIONS}
		echo "."
		;;
	reload|restart|force-reload)
		echo -n "Restarting ident daemon:"
		echo -n " oidentd"
		start-stop-daemon --stop --quiet --exec ${OIDENTD} -- ${OPTIONS}
		sleep 2
		start-stop-daemon --start --quiet --exec ${OIDENTD} -- ${OPTIONS}
		echo "."
		;;
	*)
		echo "Usage: $0 {start|stop|restart|reload|force-reload}"
		exit 1
		;;
esac

exit 0

