#!/bin/bash
#
#  Copy this file to the /etc/hotplug/usb directory
#
#

#echo "$(date) ******* usb-storage $0 $@ $ACTION RUNNING *******" >> /etc/hotplug/temp.txt

if [ -f /etc/default/hotplug ]; then
    . /etc/default/hotplug
fi

cd /etc/hotplug
. hotplug.functions

LMPIDFILE=/var/run/LMinput.pid

case $ACTION in

	add)
		if [ -r $LMPIDFILE ]; then
#			kill -USR1 `cat $LMPIDFILE`
#			killall -USR1 watchdog
			killall -USR1 wish
		fi
		;;
	
	remove)
		if [ -r $LMPIDFILE ]; then
#			kill -USR2 `cat $LMPIDFILE`
#			killall -USR2 watchdog
			killall -USR2 wish
		fi
        
        # if running kernel 2.4 remove usb-storage module to get the mount point
        #  to be /dev/sda each time a device is plugged in.  Fixed in kernel 2.6
        if [ -r "/proc/sys/cpu/0/speed" ]; then
    		sleep 1
    		rmmod usb-storage
        fi
		;;

esac

