#!/bin/ksh -p
# $Id: //depot/stable/explorer/tools/vtsst#2 $
# 
# Explorer Version:
EXP_VERSION=4.0
#

# Source tools functions
. ${EXP_LIB}/exp_tools

# Run if specified to do so
script=${0##*/}
which_gate_exit storage stortools st4 vts $script default all

TEXT=`gettext "StorTools Diagnostics not installed"`
require "pkginfo -q SUNWvtsst" "${TEXT}"

ROOT=`pkginfo -r SUNWvtsst`

# Get StorTools 4.0 log files
get_file "/var/opt/SUNWvtsst/logs/sunvts.err"   vtsst/
get_file "/var/opt/SUNWvtsst/logs/activity.log" vtsst/
get_file "/var/opt/SUNWvtsst/logs/*.errlog"     vtsst/

# Which binary should be used
ARCH=`isainfo -k`
if [ "${ARCH}" = "sparcv9" ]
then
    VTSPATH="${ROOT}/SUNWvtsst/bin/sparcv9"
else
    VTSPATH="${ROOT}/SUNWvtsst/bin"
fi

# Only run discman if Solaris 8 10/00 or better
REL=`uname -r | awk -F\. '{ print $2 }'`
if [ "${REL}" -ge 8 ]
then
    # If this is Solaris 8, skip 8, 6/00
    if [ ${REL} -eq 8 ]
    then
	# Solaris 8
        egrep -s -e "Solaris 8 s28" /etc/release && SKIP=notempty

	# Solaris 8 6/00
	egrep -s -e "Solaris 8 6/00 s28" /etc/release && SKIP=notempty
    fi

    if [ -z "${SKIP}" ]
    then
	# Validate/Create Snapshot
	if [ -f "/var/opt/SUNWvtsst/logs/SnapShot.log" -o -f "/var/opt/SUNWvtsst/logs/snapshot.log" ]
	then
	    get_cmd "${VTSPATH}/discman -v" vtsst/discman_-v
	else
	    get_cmd "${VTSPATH}/discman -c" vtsst/discman_-c
	fi
    fi
fi

# Get SnapShot data
get_file "/var/opt/SUNWvtsst/logs/[Ss]nap[Ss]hot.log"   vtsst/
get_file "/var/opt/SUNWvtsst/logs/[Ss]nap[Ss]hot.diffs" vtsst/
