#!/bin/sh
#
# ivman		A volume manager daemon
#
# chkconfig:	345 99 03
#
# description:	Ivman is a volume manager daemon. It detects added \
#		volumes such as DVDs, CDs, and USB sticks / hard \
#		drives, mounts them if necessary and also starts \
#		programs to handle the added media (such as an \
#		audio CD player, or a video DVD player). It can \
#		also monitor properties of hardware and execute \
#		commands when these properties change to a predefined value.\
#		See http://ivman.sourceforge.net
#

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

DAEMON=/usr/bin/ivman
LOCKFILE=/var/lock/subsys/ivman
PIDFILE=/var/run/ivman.pid
RETVAL=0

start()
{
	start_daemon --pidfile "$PIDFILE" \
		     --lockfile "$LOCKFILE" \
		     -- $DAEMON
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" \
		    --lockfile "$LOCKFILE" \
		    -- $DAEMON
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

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

exit $RETVAL
