#!/bin/sh
#
# Copyright (c) 1994 Sun Microsystems, Inc.
#
#ident "@(#)findssa.sh 1.4    95/05/04 SMI"
#
# This simple script will scan the /dev/rdsk directory and produce
# a unique list of controllers in the form of cX. For each
# of these controllers it will do an ssacli/ssaadm inq to see if its
# a pluto. If not its just skipped, if it is the serial number
# is saved. 
#
# We then need to scan the /dev/rdsk directory and get the physical
# path for the pluto controllers we have found. We then save these
# to a file.
#
Tmp=${1:-/var/tmp/Tmp.$$}
if [ -x /usr/sbin/ssaadm ]; then
  SSACLI=/usr/sbin/ssaadm
else
  SSACLI=/opt/SUNWssa/bin/ssacli
fi
cd /dev/rdsk
ctl=`/bin/ls | sed 's/t.*$//' | uniq`
for i in $ctl;
do
 sn=`${SSACLI} inq $i 2>/dev/null | grep 'Serial Number'`
 if [ $? -eq 0 ]; then
 serial_num=`echo $sn | sed 's/^Serial Number//'`
 echo $serial_num
  cnums=`/bin/ls ${i}t*`
  for c in $cnums
  do
    if [ -h $c ]; then
     /bin/ls -l $c  | sed -e 's/^.*->//' | \
       sed -e 's/^.*\.\.\/\.\.//' -e 's%^\(.*\)/\(.*\)%\1:ctlr%' >> $Tmp
     break
    else
      echo fails  # Should never get here!
    fi
  done
 fi
done
