#!/bin/ksh
#
#pragma ident "@(#)tests1.tst	1.7      01/07/27 SMI"
# 
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#
#
# Original Author: Michael Koller
# Modified by:	   Alex Kaplan
#

# variables
hctsdir=SUNWhcts			# base directory
hname=$1			# test system
testcmd=tests/str/cdrom.stf	# storage test
prgdir=prgs			# program directory
dls=				# data list
inst=1
# functions

# do function
go_fun()
{
	$prgdir/funcs "$*" 2>&1
}	

### MAIN ###

# change to base directory
cd `dirname $0`
while [ `basename $PWD` != $hctsdir ]
do
	cd ..
done

# set local/remote
if [ `hostname` = $hname ]
then
	# check for volume manager
	if [ -z "`ps -e | grep vold`" ]
	then
		cdtrg=`cat /etc/mnttab | grep "/cdrom/" | awk '{print $2}' | sort +1n | sed -n '1p'`
	else
		volcheck
		cdtrg=`df -kl | grep "/cdrom/" | awk '{print $6}' | sort +1n | sed -n '1p'`
	fi
else
	# check for volume manager
	cdtrg=`rsh -n $hname "ps -e" | grep vold 2>/dev/null`
	if [ -z "$cdtrg" ]
	then
		cdtrg=`rsh -n $hname "cat /etc/mnttab" | grep "/cdrom/" | awk '{print $2}' | sort +1n | sed -n '1p'`
	else
		rsh -n $hname volcheck
		cdtrg=`rsh -n $hname "df -kl" | grep "/cdrom/" | awk '{print $6}' | sort +1n | sed -n '1p'`
	fi
fi

dls=$cdtrg

# cdrom
if [ -z "$dls" ] 
then
	echo "No CDROM found. Check if CD was inserted into CD-ROM drive."
	exit 2
else
	echo "h:<HR><B><U>System certification test - CDROM</U></B>:"
	echo "h:Mount point = $dls:"
	echo "X:4:$testcmd"
	echo "T:Enter CDROM target:$dls"	
	echo "x:5:"	

	go_fun runt 1 0 1 $inst 
fi

