#!/bin/sh
#
# hotplug This scripts starts hotpluggable subsystems.
#
# chkconfig: 2345 01 99
# 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.
#
# $Id: hotplug,v 1.3 2002/12/03 02:01:48 dbrownell Exp $
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin

# source function library
if [ -f /etc/init.d/functions ]; then
	. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
	. /etc/rc.d/init.d/functions
fi

# source defaults
if [ -f /etc/sysconfig/hotplug ]; then
	. /etc/sysconfig/hotplug
fi

run_rcs () {
    for RC in /etc/hotplug/*.rc
    do
	eval "doit=\"\$HOTPLUG_RC_$(basename $RC .rc)\""
	if [ "$doit" != yes -a "$1" != status ]; then
	    continue
	fi
	$RC $1
    done
}

case "$1" in
    start|restart)
	run_rcs $1
	touch /var/lock/subsys/hotplug
	;;
    status)
	run_rcs status
	;;
    stop)
	#run_rcs stop
        rm -f /var/lock/subsys/hotplug
        ;;
    force-reload)
	run_rcs stop
	run_rcs start
	touch /var/lock/subsys/hotplug
        ;;

    *)
	gprintf "Usage: %s {start|stop|restart|status|force_reload}\n" "$0"
	exit 3
	;;
esac
