#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/cspoc/utilities/clresactive.sh 1.7.2.6 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 1996,2011 # 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 # @(#)57 1.7.2.6 src/43haes/usr/sbin/cluster/cspoc/utilities/clresactive.sh, hacmp.cspoc, 61haes_r714 11/28/11 15:06:23 # # COMPONENT_NAME: CSPOC # # FUNCTIONS: # # ORIGINS: # # # (C) COPYRIGHT International Business Machines Corp. 1996 # All Rights Reserved # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # ############################################################################### # # Name: # clresactive.sh # # Description: # clresactive returns one of yes, no, active, or inactive depending on # the accessibility of some resource specified on the command line. # Resources that may be queried are: # -v volume group # -l logical volume # -f filesystem # -u user # -g group # -V HACMP version # -c cmd[::cmd...] # # Usage: clresactive {-v ,-l ,-f ,-u ,-g ,-V ,-c } # # Return Values: # 0 success # 1 failure # ################################################################################ set -u #usage="clresactive {-v ,-l ,-f ,-u ,-g ,-V ,-v ,-l ,-f ,-u ,-g ,-V ,-v &1) # lsvg output plus any error msgs then if print -- "$lsvg_out" | grep -qi "varyonvg" then # : Error message indicates not varied on # leave "inactive" else # : Volume group is not known on this node # leave "no" fi else if print -- "$lsvg_out" | grep -i -q "passive-only" then # : Varied on in passive mode - varyonvg -c -P : Note that this test must preceed the test for 'concurrent', : since the VM mode is 'concurrent' in that case # leave "passive" elif print -- "$lsvg_out" | grep -i -q 'VG Mode: * Concurrent ' then # : Varied on in concurrent mode - varyonvg -c # leave "concurrent" elif print -- "$lsvg_out" | grep -i -q 'VG STATE: * active ' then # : Ordinary serial access varyon - varyonvg # leave "active" fi fi fi # : asked for an LV # if [[ -n $lv ]] then STATE=$(LC_ALL=C lslv $lv 2>/dev/null | sed -n '/LV STATE:/s/.*LV STATE: *\([^ ]*\).*/\1/p') case $STATE in opened/* | closed/*) STATE=active ;; \?) STATE=inactive ;; *) STATE=no ;; esac leave "$STATE" fi # : asked for an FS # if [[ -n $fsys ]] then if ! lsfs $fsys > /dev/null 2>&1 then leave "no" # file system not known on this node fi if mount | grep -qw $fsys then leave "active" # file system is mounted else leave "inactive" # file system is not mounted fi fi # : asked for a user # if [[ -n $user ]] then if lsuser $user >/dev/null 2>&1 then leave "yes" else leave "no" fi fi # : asked for a group # if [[ -n $group ]] then if lsgroup $group >/dev/null 2>&1 then leave "yes" else leave "no" fi return 0 fi # : asked for HACMP version check # if (( $version != 0 )) then # : Determine HACMP version # integer V R M F typeset -Z2 R # two digit release typeset -Z3 M # three digit modification typeset -Z3 F # three digit fix lslpp -lcqOr cluster.es.server.rte 2>/dev/null | \ cut -f3 -d':' | IFS=. read V R M F V=$V$R$M$F if [[ -z $V ]] || (( $V < $version )) then leave "no" else leave "yes" fi fi # : Run arbitrary commands # if [[ -n $cmds ]] then for cmd in $(print "$cmds" | sed -e 's/::/ /g') do c=$(print $cmd | tr ":" " ") print "__CSPOC_NODE_CMD__$c" $c 2>&1 print "__CSPOC_RETCODE__$?" done print "__CSPOC_CMD_END__" return 0 fi # should never get here, but just in case... exit 1