#!/bin/sh
#
# haldaemon	HAL daemon
#
# chkconfig:	345 98 02
#
# description:	This is a daemon for collecting and maintaing information \
#               about hardware from several sources. \
#               See http://www.freedesktop.org/software/hal
#


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

# Include debbuging statment
. /etc/sysconfig/hald

start() {
	# First step: check for running messagebus service
	if [ -f /var/lock/subsys/messagebus ]; then
		# Check if the service is already running?
		if [ ! -f /var/lock/subsys/haldaemon ]; then
		    msg_starting haldaemon
		    # Syslog output
			if is_yes "$USE_SYSLOG"; then
				daemon hald --use-syslog
			else
				daemon hald
			fi
		    RETVAL=$?
		    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/haldaemon
		else
		    msg_already_running haldaemon
		fi
	else
		msg_not_running messagebus
	fi
}

stop() {
	if [ -f /var/lock/subsys/haldaemon ]; then
		# Stop daemons.
		msg_stopping haldaemon
		killproc hald
		rm -f /var/lock/subsys/haldaemon
	else
		msg_not_running haldaemon
	fi
}

# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
	stop
	start
	;;
  reload|force-reload)
	if [ -f /var/lock/subsys/haldaemon ]; then
		msg_reloading haldaemon
		killproc hald -HUP
		RETVAL=$?
	else
		msg_not_running haldaemon
		RETVAL=7
	fi
	;;
  status)
	status hald
	RETVAL=$?
	;;
  *)
	msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
	exit 3
esac

exit $RETVAL

# This must be last line !
# vi:syntax=sh
