#!/bin/sh
#
# $Id$
#
# This script sets up the USB media
#

# Get info from config file
usbdev=`grep usb-dev /tmp/mondo-restore.cfg | cut -d' ' -f2-`

# info from cmdline are predominent
for i in `cat /proc/cmdline` ; do
	echo $i | grep -qi usb= && usbdev=`echo $i | cut -d= -f2`
done

if [ $usbdev = "" ]; then
	# No usb configuration neither stored during archive
	# nor on cmdline so no usb wanted => exiting
	exit 0
fi

needusbstorage=`LC_ALL=C grep -e "^I.*Cls=08" /proc/bus/usb/devices 2>/dev/null`
unamer=`uname -r`
min=`echo $unamer | cut -d. -f2`
[ -n "$needusbstorage" -a "$min" = "4" ] && /sbin/modprobe usb-storage >/dev/null 2>&1

[ -d /proc/bus/usb ] && ! grep -q /proc/bus/usb /proc/mounts && mount -t usbfs none /proc/bus/usb

LogIt "Mounting USB device (${usbdev}1) on /mnt/cdrom..."
sync
sleep 2
ls -l ${usbdev}1
mount -t vfat ${usbdev}1 /mnt/cdrom
/sbin/modprobe usb-storage
sleep 10
ls -l ${usbdev}1
mount -t vfat ${usbdev}1 /mnt/cdrom
