#!/bin/sh
#
# hotplug	This scripts starts hotpluggable subsystems.
#
# chkconfig:	2345 08 92
# description:	Starts and stops each hotpluggable subsystem. \
#		On startup, may simulate hotplug events for devices \
#		that were present at boot time, before filesystems \
#		used by /sbin/hotplug became available.
#
# $Id: hotplug.init,v 1.8 2003/09/23 11:27:08 twittner Exp $
#

# 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/hotplug ]; then
		msg_starting "hotplug"
		busy
		for RC in /etc/hotplug/*.rc; do
			$RC start
			RET=$?
			[ $RETVAL -eq 0 ] && RETVAL=$RET
		done
		[ $RETVAL -eq 0 ] && ok || fail
		touch /var/lock/subsys/hotplug
	else
		msg_already_running "hotplug"
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/hotplug ]; then
		msg_stopping "hotplug"
		busy
		for RC in /etc/hotplug/*.rc; do
			$RC stop
		done
		ok
		rm -f /var/lock/subsys/hotplug >/dev/null 2>&1
	else
		msg_not_running "hotplug"
	fi
	;;
  status)
  	for RC in /etc/hotplug/*.rc; do
		$RC status
		RET=$?
		[ $RETVAL -eq 0 ] && RETVAL=$RET
	done
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
