#!/bin/sh
# oddjobd       This shell script takes care of starting and stopping
#               oddjobd.
#
# chkconfig: - 98 02
# description: oddjobd provides support for unprivileged applications which \
#	       require one of a set of specified privileged operations to be \
#	       performed on their behalf.
#
### BEGIN INIT INFO
# Provides: oddjobd
# Required-Start: $local_fs $remote_fs messagebus
# Required-Stop: $local_fs $remote_fs messagebus
# Short-Description: start and stop oddjob services
# Description: The oddjob service provides support for unprivileged
#     applications which require one of a set of specified privileged
#     operations to be performed on their behalf.
### END INIT INFO

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

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

start()
{
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- oddjobd -p "$PIDFILE" -t 300
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- oddjobd
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	msg_reloading oddjobd
	stop_daemon --pidfile "$PIDFILE" --expect-user root -HUP -- oddjobd
	RETVAL=$?
	return $RETVAL
}

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

exit $RETVAL
