#!/bin/ksh -p
# $Id: //depot/stable/explorer/tools/fru#2 $
#
# Explorer Version:
EXP_VERSION=4.0
#
# Source tools functions
. ${EXP_LIB}/exp_tools

script=${0##*/}
which_gate_exit $script default all

TEXT=`gettext "FRUid not installed"`
require "pkginfo -q SUNWfruid" "${TEXT}"

# Check version release of OS.  
# FRU data is not to be collected for SF15K running solaris 5.8 or 5.9

# System Controller submission requirements.
# Check if server is a SF15K by checking for SUNWSMSr package.

# Domain requirements
# Check if server is a SF15K by checking the platform type.

# Do not collect FRU data on SF15K servers running Solaris 5.8 or 5.9
# On SF15K server, only collect FRU data if running Solaris 5.10 or higher.

# Collect FRU data on servers that are not SF15K regardless of OS release level.

# Allow override with the -w fru command.

which_gate $script
if [[ $? = 0 ]]
then
	get_cmd "/usr/sbin/prtfru -x" fru/
else
	if [[ `uname -r` = 5.[89] ]]
	then 
		pkginfo -q SUNWSMSr
		if [ "$?" = 0 ]
		then
			TEXT="Solaris OS release level is `uname -r`\nFRU data not collected on SF15Ks running below Solaris 5.10\n"
			[ ! -d "{EXP_TARGET}/${script##*/}" ] && { mkdir -p ${EXP_TARGET}/${script##*/}; }
			logger -p daemon.notice -t explorer "${TEXT}"
			echo "${TEXT}" >> ${EXP_TARGET}/${script##*/}.error
			
		elif [[ `uname -i` = "SUNW,Sun-Fire-15000" ]]
		then
			TEXT="Solaris OS release level is `uname -r`\nFRU data not collected for domains SF15Ks running below Solaris 5.10\n"
			[ ! -d "{EXP_TARGET}/${script##*/}" ] && { mkdir -p ${EXP_TARGET}/${script##*/}; }
			logger -p daemon.notice -t explorer "${TEXT}"
			echo "${TEXT}" >> ${EXP_TARGET}/${script##*/}.error
		else
			get_cmd "/usr/sbin/prtfru -x" fru/
		fi
	else
		get_cmd "/usr/sbin/prtfru -x" fru/
	fi
fi
