#!/bin/ksh93
#  ALTRAN_PROLOG_BEGIN_TAG                                                     
#  This is an automatically generated prolog.                                  
#                                                                              
#  Copyright (C) Altran ACT S.A.S. 2022.  All rights reserved.         	
#                                                                              
#  ALTRAN_PROLOG_END_TAG                                                       
#                                                                              
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/cspoc/utilities/cli_mklvcopy.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2007 
# 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 
# @(#)  d3feddf 43haes/usr/sbin/cluster/cspoc/utilities/cli_mklvcopy.sh, 61aha_r726, 2205A_aha726, Apr 01 2022 02:28 PM

###############################################################################
#
#   COMPONENT_NAME: CSPOC Command Line Interface
#
# Name:
#   cli_mklvcopy
#
# Description:
#   Use C-SPOC to run the mklvcopy command with the given parameters and make the
#   updated logical volume definition known on all cluster nodes
#
# Arguments:
#   Same as for the mklvcopy command 
#
#   Arguments are not validated by this routine; any errors in arguments are
#   caught either by cl_mklvcopy.cel, or by the mklvcopy system function.
#
#   Setting the environment variable _DEBUG to 1 -> 9 turns on levels of
#   C-SPOC debugging
#
# Return Values:
#   As set by cl_mklvcopy
#
# Notes:
#   The '-f' flag is passed on cl_mklvcopy to surpress unnecessary checking.
#   As a consequence, the operation will proceed even if not all nodes are
#   accessable
#
################################################################################


typeset DEBUG

#
#   Variables needed by cl_mklvcopy
#	_CSPOC_MODE - working with shared (as opposed to concurrent) volume
#			groups
#	_CSPOC_CALLED_FROM_SMIT - can skip checks on input
#
export _CSPOC_MODE="shared"
export _CSPOC_CALLED_FROM_SMIT="true"

#
#   If a _DEBUG value has been set, pass it through
#
if [[ -n $_DEBUG ]] ; then

    #
    #	The debug level is a number, 1 through 9.  Those values are passed
    #	through.  Anything else is turned into '1'
    #
    integer dbg_level=$_DEBUG
    if (( $dbg_level < 10 && $dbg_level >= 1 )) ; then
	DEBUG="-d $_DEBUG"
    else
	DEBUG="-d 1"
    fi
fi

#
#   Construct the node list.  This is a comma separated, quote delimited list
#   of all the nodes in the cluster.
#
export _NODE_LIST=$(IFS=, set -- $(odmget -q "object = VERBOSE_LOGGING" HACMPnode | \
		    sed -n '/name =/s/^.*name = "\(.*\)"/\1/p') ; print "$*")

#
#   Invoke the cspoc code to create the file system and make it known across
#   the cluster
#
local_node=$(/usr/es/sbin/cluster/utilities/get_local_nodename)
/usr/es/sbin/cluster/sbin/cl_mklvcopy -cspoc "-f $DEBUG -n $_NODE_LIST" -R $local_node $*
return $?