#!/bin/sh
#
# idled		daemon that terminates idle user sessions
#
# chkconfig:	345 95 05
#
# description:	idled keeps an eye on every users session, and terminates \
# 		them when user has been idle or logged in for too long
#

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

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/idled ]; then
		msg_starting idled
		daemon idled
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/idled
	else
		msg_already_running idled
	fi
	;;
  stop)
	# Stop daemons.
	if [ -f /var/lock/subsys/idled ]; then
		msg_stopping idled
		killproc idled
		rm -f /var/lock/subsys/idled >/dev/null 2>&1
	else
		msg_not_running idled
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status idled
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
        exit 3
esac

exit $RETVAL
