#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/ccs/lib/libclcmd/check_pha.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2010 
# 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 
# @(#)63 1.1 src/bos/usr/ccs/lib/libclcmd/check_pha.sh, libcluster, bos720 4/13/10 12:32:11
#----------------------------------------------------------------------------#
# check_pha - Check presence and version of PowerHA
#
# This command checks two conditions:
#   1. Is PowerHA installed?
#   2. Is the version of PowerHA 7.x or later?
#
# Returns:
#   0 - If both conditions are true.
#   1 - If either condition is false.
#----------------------------------------------------------------------------#
#set -x
#
# See if PowerHA is installed.  If not then return 1.
#
  lslppout=$(LC_ALL=C /usr/bin/lslpp -Lcq cluster.es.cspoc.cmds 2>/dev/null)
  rc=$?
  if [[ $rc -ne 0 ]]; then
      return 1
  fi

#
# PowerHA is installed.  Now parse the output of lslpp to see if the
# PowerHA level is 7.x or greater.  If so then return 0.  Otherwise
# return 1.
#
  phaversion=${lslppout#*cluster.es.cspoc.cmds:} # Remove before and 
  phaversion=${phaversion%%.*}                   #   after version...
# print "PowerHA Version: $phaversion \n"
  if [[ $phaversion -ge 7 ]]; then
      return 0
  fi
  return 1
