#!/bin/sh
#
# HardDrake	This scripts runs the HardDrake hardware probe in 
#		(kuzdu mode).
#
# chkconfig: 345 05 95
# description: 	HardDrake runs a hardware probe, and optionally \
#		configures new/changed hardware.
# config: /etc/sysconfig/harddrake/harddrake.xml

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

RETVAL=$?

case "$1" in
  start)
	echo -n "Loading HardDrake"
	/usr/sbin/harddrake-text --boot
	RETVAL=$?
	if [ "$RETVAL" -eq 0 ]; then
		action "" /bin/true
	else
		action "" /bin/false
	fi
	
	# We don't want to run this on random runlevel changes.
	touch /var/lock/subsys/harddrake
	# However, if they did configure X and want runlevel 5, let's
	# switch to it...
	if [ -f /tmp/ranXconfig ]; then
		grep -q "^id:5:initdefault:" /etc/inittab && telinit 5
	fi
	;;
 status)
	if [ -f /var/lock/subsys/harddrake ]; then
		echo "HardDrake loaded"
	fi
	;;
 reload)
	$0 stop
	$0 start
	;;	
 restart)
	$0 stop
	$0 start
	;;	
 stop)
	rm -f /var/lock/subsys/harddrake
	;;
  *)
	echo "Usage: harddrake {start|stop|status|restart}"
	exit 1
	;;
esac

exit $RETVAL
