#! /bin/sh # # $Id: cluster_validate.sh,v 1.3 2006/04/24 15:55:17 castrv Exp $ Copyright (c) 2003-2006, EMC Corporation. # # All rights reserved. # # Validate method for HA NetWorker Server (LGTO.serv resource type) # This method validates the Config_dir property of the resource. The Validate # method gets called in two scenarios. When the resource is being created and # when a resource property is getting updated. When the resource is being # created, this method gets called with the -c flag and all the system-defined # and extension properties are passed as command-line arguments. # When a resource # property is being updated, the Validate method gets called with the -u flag, # and only the property/value pair of the property being updated is passed as a # command-line argument. # # ex: When the resource is being created command args will be # # networker.validate -c -R <..> -G <...> -T <..> -r ... # -x .... -g .... # # when the resource property is being updated # # networker.validate -u -R <..> -G <...> -T <..> -r # OR # networker.validate -u -R <..> -G <...> -T <..> -x # # NOTE: extension property config_dir cannot be updated since it is # tunable AT_CREATION only # scrgadm will print an error message if admin tries to update it # # parse program arguments. # parse_args() { while [ $# -gt 0 ] do case $1 in -R ) RESOURCE_NAME=$2 shift ;; -T ) RESOURCETYPE_NAME=$2 shift ;; -G ) RESOURCEGROUP_NAME=$2 shift ;; -r ) # The method is not accessing any system defined # properties, so this is a no-op. shift ;; -g ) # The method is not accessing any resource group # properties, so this is a no-op. shift ;; -c ) # Indicates the Validate method is being called while # creating the resource, so this flag is a no-op. ;; -u ) # Indicates the updating of a property when the # resource already exists. UPDATE_PROPERTY=1 ;; -x ) # Extension property list. Separate the property and # value pairs using "=" as the separator. PROPERTY=`echo $2 | awk -F= '{print $1}' | \ tr "[A-Z]" "[a-z]"` VAL=`echo $2 | awk -F= '{print $2}'` # If the Confdir extension property is found on the # command line, note its value. if [ X${PROPERTY} = "Xconfig_dir" ]; then CONFDIR=$VAL CONFDIR_FOUND=1 fi shift ;; * ) # Just ignore everything else... ;; esac shift done } ############################################################################## # # MAIN # ############################################################################## PATH=/bin:/usr/bin:/usr/cluster/bin:/usr/sbin:/usr/proc/bin:$PATH export PATH if [ -f /bin/hostname ]; then HOSTNAME=`/bin/hostname` elif [ -f /usr/ucb/hostname ]; then HOSTNAME=`/usr/ucb/hostname` elif [ -f /usr/bsd/hostname ]; then HOSTNAME=`/usr/bsd/hostname` elif [ -f /usr/local/bin/hostname ]; then HOSTNAME=`/usr/local/bin/hostname` else HOSTNAME= fi if [ X${HOSTNAME} = X ]; then HOSTNAME=`uname -n` fi BASE=`basename $0` # Obtain the syslog facility to use to log messages. SYSLOG_FACILITY=`scha_cluster_get -O SYSLOG_FACILITY` LOGERR="logger -t '$HOSTNAME:$BASE' -p ${SYSLOG_FACILITY}.err" LOGINFO="logger -t '$HOSTNAME:$BASE' -p ${SYSLOG_FACILITY}.info" # Set the Value of CONFDIR to null. Later, this method retrieves the value # of the Confdir property from the command line CONFDIR="" UPDATE_PROPERTY=0 CONFDIR_FOUND=0 # Parse the arguments that have been passed to this method. parse_args $* # If the validate method is being called due to the updating of properties # there are no properties for us to verify if [ $UPDATE_PROPERTY = 1 ]; then # Log a message indicating that the Validate method was successful. $LOGINFO "Validate method for resource "$RESOURCE_NAME \ " completed successfully" exit 0 fi # Verify that the Confdir property has a value. If not there is a failure # and exit with status 1. if [ -z "$CONFDIR" ]; then $LOGERR "Validate method for resource "$RESOURCE_NAME " failed" $LOGERR "Config_dir extension propery doesn't have a value" exit 1 fi # Now validate the actual Confdir property value. # Check if $CONFDIR is accessible. if [ ! -d $CONFDIR ]; then $LOGERR "Validate method for resource "$RESOURCE_NAME " failed" $LOGERR "Directory $CONFDIR missing or not mounted" exit 1 fi # Log a message indicating that the Validate method was successful. $LOGINFO "Validate method for resource "$RESOURCE_NAME \ " completed successfully" exit 0