#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/utilities/cl_aixlevel.sh 1.2 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2004,2014 
# 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 
# \$Id\$

###############################################################################
#
#   COMPONENT_NAME: CSPOC
#
#   ORIGINS: 27
#
# Name:
#   cl_aixlevel
#
#
# Description:
#   Determine and print out the bos VRMF level
#
#   Usage: cl_aixlevel
#
# Arguments:
#   None
#
#
# Return Values:
#   bos VRMF as a 10 digit integer of the form VVRRMMMFF
#
#   Questions?  Comments?   Expressions on Astonishment?    mailto:hafeedbk@us.ibm.com
#
#
################################################################################


    #    Each of the V, R, M and F fields are padded to fixed length,
    #    to allow reliable comparisons.  E.g., maximum VRMF is
    #    99.99.999.999
    integer V R M F
    typeset -Z2 V			# two digit version
    typeset -Z2 R			# two digit release
    typeset -Z3 M			# three digit modification
    typeset -Z3 F			# three digit fix

    #    Here try and figure out what level of AIX is installed.
    #    Depending on which of the three kernels is in use, three
    #    possible filesets have to be checked.
    if lslpp -lcq bos.mp64 2>/dev/null | cut -f3 -d':' | IFS=. read V R M F
    then
       :				# V R M and F are set from bos.mp64

    elif lslpp -lcq bos.mp 2>/dev/null | cut -f3 -d':' | IFS=. read V R M F
    then
       :				# V R M and F are set from bos.mp

    elif lslpp -lcq bos.up 2>/dev/null | cut -f3 -d':' | IFS=. read V R M F
    then
       :				# V R M and F are set from bos.up
    fi
    print $V$R$M$F			# get the AIX level