#!/bin/sh
#
# Midas Custom Hotplug Helper Script.
#   For the DL4 console we're only interested in USB storage devices, and
#   within that context all we want to do is automatically mount and
#   unmount devices as they are added and removed.
#   This script simply forwards the event on to the binary application
#   that hopefully does this. The kernel does everything else.
#

#
# We're looking for usb storage. Investigation has shown that when the kernel
# invokes this script, 'the hotplug helper', with the argument 'usb' the
# device has not actually been assigned/removed from its associated /dev/sdxx
# device node. Infact when now look for 'scsi_device' invocations.
#
udevsend
if [ $1 == "scsi_device" ]; then

	# Service the event.
	# NOTE: If trying to debug problems add '-debug' to the end of the
	#       USBHotplug command.
	sleep 5
	/opt/midas/bin/usbhotplug -hotplug

else
	# Log the event but ignore.
	/usr/bin/usbhotplug -log "$0 invoked with parameters [$*]"

fi


exit 1
