#!/bin/ksh93
#  ALTRAN_PROLOG_BEGIN_TAG                                                     
#  This is an automatically generated prolog.                                  
#                                                                              
#  Copyright (C) Altran ACT S.A.S. 2021.  All rights reserved.         	
#                                                                              
#  ALTRAN_PROLOG_END_TAG                                                       
#                                                                              
#
# @(#)  05e9b00 43haes/usr/sbin/cluster/cspoc/utilities/cli_chgrpmem.sh, 726, 2147A_aha726, May 19 2021 09:53 PM

###############################################################################
#
# Name: cli_chgrpmem
#
# Description:
#   Use C-SPOC to run the chgrpmem command with the given parameters to modify
#   the given user group on all cluster nodes
#
# Arguments:
#   Same as for the chgrpmem command; assumed validated by caller
#
#   Setting the environment variable _DEBUG to 1 -> 9 turns on levels of
#   C-SPOC debugging
#
# Return Values:
#   As set by cl_chgrpmem
#
# Notes:
#   The '-f' flag is passed on cl_chgrpmem to surpress unnecessary checking.
#   As a consequence, the operation will proceed even if not all nodes are
#   accessable, the group does not exist, etc
#
################################################################################

typeset PROGNAME=${0##*/}
export PATH="$(/usr/es/sbin/cluster/utilities/cl_get_path all)"

typeset DEBUG

#
#   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

export _CSPOC_CALLED_FROM_SMIT="true" # tell cspoc skip checks on inputs

#
#   Construct the node list as a comma separated list
#   of all the nodes in the cluster.
#
export _NODE_LIST=$(clnodename | paste -s -d ',' -)

#
#   Invoke the cspoc code to change the user group across the cluster
#
cl_chgrpmem -cspoc "-f $DEBUG -n $_NODE_LIST" $*
return $?