#!/bin/bsh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos72L src/bos/diag/diags/get_diag_stanzas.sh 1.7.1.2 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 1993,2018 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)76	1.7.1.2  src/bos/diag/diags/get_diag_stanzas.sh, diagsup, bos72L, l2018_07A2 1/30/18 13:37:39
#
# COMPONENT_NAME: CMDDIAG  DIAGNOSTIC SUPERVISOR
#
# FUNCTIONS: Gather Diagnostic ODM stanzas of all disks.
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1993, 1995
# All Rights Reserved
# Licensed Materials - Property of IBM
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#                                                                   
###################################################################

DIAGDATA=/etc/lpp/diagnostics
DIAGDATADIR=$DIAGDATA/data


##############################################################
# Check to see if diagnostics can be run on this platform
##############################################################

/usr/sbin/bootinfo -M >/dev/null 2>&1
if [ "$?" -ne 101 -a "$?" -ne 103 ]
then
    /usr/bin/dspmsg -s 4 diagcd.cat 1 \
        "\n\nThe 'get_diag_stanzas' command is not supported on this system.\n\n"
    exit 0
fi

if [ $1 ]
then
	odmdir=$1
else
	odmdir=`pwd`
fi
/usr/bin/odmshow PDiagDev PDiagAtt CDiagDev TMInput FRUB FRUs MenuGoal DAVars PDiagRes PDiagTask CDiagAtt PDiagELA PDiagSRN PDiagFRU PDiagTU PDiagMcode \
	> $DIAGDATADIR/diagodm.cre
ODMDIR=$odmdir /usr/bin/odmcreate -c $DIAGDATADIR/diagodm.cre >/dev/null 2>&1
if [ $? != 0 ]
then
	echo "Unable to create empty diagnostics object class."
	/usr/bin/rm -rf $DIAGDATADIR/diagodm.cre >/dev/null 2>&1
	exit 1
fi
/usr/bin/odmget -q"DClass=disk" PDiagDev > $DIAGDATADIR/diskdiag.stz
/usr/bin/odmget -q"DClass=disk" PDiagAtt >> $DIAGDATADIR/diskdiag.stz
/usr/bin/odmget -q"Uniquetype like disk/*" PDiagRes >> $DIAGDATADIR/diskdiag.stz

ODMDIR=$odmdir /usr/bin/odmadd $DIAGDATADIR/diskdiag.stz
if [ $? != 0 ]
then
	echo "Unable to populate diagnostics object class."
	/usr/bin/rm -rf $DIAGDATADIR/diskdiag.stz >/dev/null 2>&1
	exit 1
fi

/usr/bin/rm -rf $DIAGDATADIR/diagodm.cre >/dev/null 2>&1
/usr/bin/rm -rf $DIAGDATADIR/diskdiag.stz >/dev/null 2>&1

exit 0
