#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r721 src/43haes/usr/sbin/cluster/sa/sap/sbin/cl_checkIsAliasAddr.sh 1.2.1.4 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2008,2016 # 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 # @(#)87 1.2.1.4 src/43haes/usr/sbin/cluster/sa/sap/sbin/cl_checkIsAliasAddr.sh, hacmp.assist.sap, 61haes_r721, 1617A_hacmp721 4/22/16 05:41:24 ## ## NAME: cl_checkIsAliasAddr ## PURPOSE: ## Checks if a given addres is an aliased address or not. ## ## ## ARGUMENTS: ## ## Type: ## IP Name ## ## ## OUTPUT: ## ## ## RETURNS: ## 0 on success ## 1 on failure ## . /usr/es/lib/ksh93/func_include typeset version='1.1' #---------------------------------------------------------------------------- # Global Definitions #---------------------------------------------------------------------------- . /usr/es/sbin/cluster/sa/sap/etc/SAPGlobals . /usr/es/sbin/cluster/sa/sap/sbin/SAPUtilities PATH=$PATH:/usr/es/sbin/cluster/sa/sbin PATH=$PATH:/usr/es/sbin/cluster/utilities #---------------------------------------------------------------------------- # Main #---------------------------------------------------------------------------- IPName=$1 #Return 1 if No IP Address is specified. [[ -z $IPName ]] && return 1 typeset interface # Below logic to filter out cases where we have multiple IPNames with same name # differentiated only by - or . # e.g. serviceip, serviceip-1, serviceip.in.ibm.com # In this case grep -w serviceip will show all the above 3. # So we need to add more checks to get exactly what we need /bin/netstat -i | grep -w "$IPName" | while read interface skip skip ip skip; do res=$(echo $ip |cut -f1 -d.) if [[ $res == "$IPName" ]] then break; fi done [[ -z $interface ]] && return 1 boot_addr=$(odmget -q "name=$interface and attribute=netaddr" CuAt | \ awk -F= '/value/ {print $2}' | sed "s/\"//g") [[ -z $boot_addr ]] && return 1 [[ "$IPName" == "$boot_addr" ]] && return 1 return 0