#!/bin/sh
#
# hotplug This scripts starts hotpluggable subsystems.
#
# chkconfig: 2345 32 69
# description:	Starts and stops each hotpluggable subsystem. \
#		On startup, may simulate hotplug events for devices \
#		that were present at boot time, before filesystems \
#		(or other resources) used by hotplug agents were available.
#

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

SourceIfNotEmpty /etc/sysconfig/hotplug

[ "$HOTPLUG" == "no" ] && exit 0

LOCKFILE=/var/lock/subsys/hotplug

RETVAL=0

[ -z "$HOTPLUGRC" ] && HOTPLUGRC="usb.rc pci.rc sound.rc"
 
run_rcs () {
    for RC in $HOTPLUGRC
    do
	action "Hotplug ($RC) $1:" /etc/hotplug/$RC $1
	RETVAL=$?
    done
}

case "$1" in
    start|restart)
	run_rcs $1
	[ $RETVAL -eq 0 ] && touch $LOCKFILE
	;;
    stop)
	run_rcs $1
        rm -f $LOCKFILE
        ;;
    force-reload)
	run_rcs $1
        ;;
    status)
	run_rcs $1
	;;
    condrestart|condstop)
	RETVAL=0
	;;
    *)
	echo $"Usage: $0 {start|stop|restart|status|force_reload|condrestart|condstop}"
	RETVAL=3
	;;
esac

exit $RETVAL
