#!/bin/sh
#@(#)photon	1.10 04/19/99 13:24:39

# Test for existance of photon
#
if [ ! -d /dev/es ] ||
   [ ! -x /usr/sbin/luxadm ] ||
   [ `luxadm probe | grep "No Network Array enclosures found"|wc -l` -ne 0 ]
then
    # Photon is not installed on this system
    exit 0
fi


BOX_DIR=disks/photon/boxnames
mkdir -p $BOX_DIR


# List all photons connected to the system
luxadm probe    1>disks/photon/luxadm_probe.out  2>disks/photon/luxadm_probe.err
luxadm probe -p 1>disks/photon/luxadm_probe-p.out 2>disks/photon/luxadm_probe-p.err

ls -l /dev/es >disks/photon/ls-l_dev.es

# get info for each photon using boxname. However, for compatibility
# with explorer pre 3.0 release, create a ses link to each boxname dir.
# This is why we are grabing boxname and Logical path for each photon.

for i in `luxadm probe|nawk '/SENA/,/Logical/'| nawk '{print $2}'`
do
    if [ "Name" = `echo $i|sed s/:.*//` ]
    then
        # Get the photon name
	BOXNAME=`echo $i|sed s/Name://`
	mkdir $BOX_DIR/$BOXNAME
	# run all of the luxadm commands
        luxadm display $BOXNAME 1>$BOX_DIR/$BOXNAME/luxadm_display.out \
    			        2>$BOX_DIR/$BOXNAME/luxadm_display.err
        sleep 1
    
        luxadm -v display $BOXNAME 1>$BOX_DIR/$BOXNAME/luxadm-v_display.out \
    				   2>$BOX_DIR/$BOXNAME/luxadm-v_display.err
        sleep 1

        luxadm display -r $BOXNAME 1>$BOX_DIR/$BOXNAME/luxadm_display-r.out \
				   2>$BOX_DIR/$BOXNAME/luxadm_display-r.err
        sleep 1

        luxadm -e dump_map $BOXNAME 1>$BOX_DIR/$BOXNAME/luxadm_-e_dump_map.out \
				    2>$BOX_DIR/$BOXNAME/luxadm_-e_dump_map.err
    else
	# for compatibility with explorer pre 3.0 release create links
	# into the BOXNAME dirs so older tools don't break.
        SES=`echo $i|sed s/Path:.dev.es.//`
	ln -s boxnames/$BOXNAME disks/photon/$SES
    fi

done
