#!/bin/sh
#
# Load USB drivers.  
# mdev may or may not do this correctly.
# So we make sure we have what we need here.
#

CNF=/etc/usbhandler.conf

case "$1" in
  start)
        echo "Loading USB drivers..."

        # Save lsusb output for parsing
        UDATA=`lsusb`

        # Read the configuration file and compare to lsusb output
        cat $CNF | grep -v "^#" | while read entry
        do
            pair=`echo $entry | cut -f1 -d" "`
            cmd=`echo $entry | cut -f2- -d" "`
            echo $UDATA | grep $pair > /dev/null 2>&1
            if [ $? -eq 0 ]
            then
                # load module quietly (-q doesn't ignore errors)
                modprobe $cmd 2> /dev/null
            fi
        done

        # Cleanup
        rm -f $LOG
        ;;
  stop) 
        ;;
  restart|reload)
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $?

