#!/bin/ksh
#
#ident	"@(#)usb_check.sh	1.3	04/12/08 SMI"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#


if [ $# -ne 2 ]; then
    echo "!ERROR: $0 <disk> <hostname>"
    exit 1
fi

disk=$1
hname=$2
usb_cmd="rsh -l root $hname /usr/sbin/cfgadm -v"
echo $disk | grep "/dev/rdsk/" > /dev/null
if [ $? -eq 0 ]
then
    disk_cmd="/bin/ls -l $disk"
else
    disk_cmd="/bin/ls -l /dev/rdsk/$disk"
fi
devices=`$usb_cmd | grep usb-storage | awk '{print $4}' | sed 's/:.*//g' 2>/dev/null`
disks=`$disk_cmd | awk '{print $11}' | sed 's/^.*\/devices/\/devices/g' 2>/dev/null`

for path in $devices
do
    ret=`echo $disks | egrep $path`
    if [ $? -eq 0 ]; then
        exit 0
    fi
done
exit 1

