#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r721 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_modify_efs.sh 1.4 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 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 # @(#)16 1.4 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_modify_efs.sh, hacmp.assist, 61haes_r721, 1618A_hacmp721 4/28/16 05:58:06 #================================================ # The following, commented line enforces coding # standards when this file is edited via vim. #================================================ # vim:tabstop=4:shiftwidth=4:expandtab:smarttab #================================================ # Start of POD-formatted documentation. Viewing suggestions: # perldoc # pod2text -c # pod2text -c --code # pod2html function devDoc { : <<'=cut' >/dev/null 2>&1 =head1 NAME KLIB_HACMP_modify_efs =head1 VERSION Version Number: 1.4 Last Extracted: 5/3/16 18:54:04 Last Changed: 4/28/16 05:58:06 Path, Component, Release(, Level): src/43haes/lib/ksh93/hacmp/KLIB_HACMP_modify_efs.sh, hacmp.assist, 61haes_r721, 1618A_hacmp721 =head1 SYNOPSIS clmgr modify efs \ [ MODE={ldap|shared_fs} ] \ [ VOLUME_GROUP= ] \ [ SERVICE_IP= ] \ [ PASSWORD= ] =head1 DESCRIPTION Attempts to enable EFS for securing file systems. =head1 ARGUMENTS 1. properties [REQUIRED] [hash ref] An associative array within which data about the created object can be returned to the caller. 2. mode [REQUIRED] [string] The manner in which the keystore will be created. More specifically, the location; either "ldap" or "shared_fs". 3. vg [OPTIONAL] [string] The volume group where the keystore is to be stored. This option is required for mode "shared_fs", but does not apply at all to a mode of "ldap". 4. service_ip [OPTIONAL] [set] The service IP that can be used to access the keystore. This option is required for mode "shared_fs", but does not apply at all to a mode of "ldap". 5. password [OPTIONAL] [string] The EFS administrative password. =head1 RETURN 0: no errors were detected; the operation appears to have been successful 1: a general error has occurred 2: a specified resource does not exist, or could not be found 3: some required input was missing 4: some detected input was incorrect in some way 5: a required dependency does not exist 6: a specified search failed to match any data =head1 COPYRIGHT COPYRIGHT International Business Machines Corp. 2005,2010 All Rights Reserved =cut } # End of POD-formatted documentation. function KLIB_HACMP_modify_efs { LINENO=2 . $HALIBROOT/log_entry "$0()" "$CL" : version=1.4, src/43haes/lib/ksh93/hacmp/KLIB_HACMP_modify_efs.sh, hacmp.assist, 61haes_r721, 1618A_hacmp721 : INPUTS: $* typeset -n properties=$1 typeset -l mode=${2//\"/} typeset vg=${3//\"/} typeset service_ip=${4//\"/} typeset password=${5//\"/} [[ $CLMGR_LOGGING == 'med' ]] && set +x # Only trace param values #=================================== : Declare and initialize variables #=================================== typeset -i rc=$RC_UNKNOWN typeset -A efs_attrs CL=$LINENO KLIB_HACMP_get_efs_attributes efs_attrs #================= : Validate input #================= CL=$LINENO KLIB_HACMP_is_known_efs if (( $? != RC_SUCCESS )); then CL=$LINENO cl_dspmsg -s 129 cspoc.cat 75 "EFS Kesytore is not configured.\n" 1>&2 rc=$RC_NOT_FOUND fi if [[ $mode != *([[:space:]]) ]]; then if [[ $mode != @(l|s|f)* ]]; then /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 110 "\nERROR: invalid value specified for \"%1\$s\": \"%2\$s\".\n" MODE "$mode " 1>&2 rc=$RC_INCORRECT_INPUT else typeset -u modeUC=$mode case $modeUC in LD*) mode="ldap" ;; LO*) mode="shared_fs" ;; F*) mode="shared_fs" ;; SH*) mode="shared_fs" ;; *) /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 110 '\nERROR: invalid value specified for "%1$s": "%2$s".\n' MODE "$mode" 1>&2 /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 3 "Valid values: %1\$s\n\n" "shared_fs, ldap" 1>&2 rc=$RC_INCORRECT_INPUT ;; esac fi fi if [[ $vg != *([[:space:]]) ]]; then if [[ ${efs_attrs[MODE]} == "ldap" || $mode == "ldap" ]]; then /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 36 "\nERROR: conflicting options were provided,\n \"%1\$s\" versus \"%2\$s\".\n\n" "MODE=$mode" VOLUME_GROUP 1>&2 rc=$RC_INCORRECT_INPUT fi fi if [[ $service_ip != *([[:space:]]) ]]; then if [[ ${efs_attrs[MODE]} == "ldap" || $mode == "ldap" ]]; then /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 36 "\nERROR: conflicting options were provided,\n \"%1\$s\" versus \"%2\$s\".\n\n" "MODE=$mode" SERVICE_IP 1>&2 rc=$RC_INCORRECT_INPUT fi fi if [[ $vg != *([[:space:]]) ]]; then CL=$LINENO KLIB_HACMP_is_known_volume_group $vg if (( $? != RC_SUCCESS )); then /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 102 "\nERROR: \"%1\$s\" does not appear to exist!\n\n" "$vg" 1>&2 /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 160 "Available Volume Groups:\n\n" 1>&2 typeset available CL=$LINENO KLIB_HACMP_list_volume_groups available for (( i=0; i<${#available[*]}; i++ )); do if [[ ${available[$i]} != *([[:space:]]) ]]; then print -u2 "\t${available[$i]}" fi done print -u2 "" rc=$RC_NOT_FOUND fi fi if [[ $service_ip != *([[:space:]]) ]]; then CL=$LINENO KLIB_HACMP_is_known_service_ip $service_ip if (( $? != RC_SUCCESS )); then /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 102 "\nERROR: \"%1\$s\" does not appear to exist!\n\n" "$service_ip" 1>&2 /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 156 "Available Service IPs:\n\n" 1>&2 typeset available CL=$LINENO KLIB_HACMP_list_service_ip available for (( i=0; i<${#available[*]}; i++ )); do if [[ ${available[$i]} != *([[:space:]]) ]]; then print -u2 "\t${available[$i]}" fi done print -u2 "" rc=$RC_NOT_FOUND fi fi #=================================================== : Enable EFS if no input errors have been detected #=================================================== if (( $rc == RC_UNKNOWN )); then typeset mOpt= vOpt= sOpt= aOpt= [[ $mode == "ldap" ]] && mOpt=" -m 1" || mOpt=" -m 2" [[ $vg != *([[:space:]]) ]] && vOpt=" -v $vg" [[ $service_ip != *([[:space:]]) ]] && sOpt=" -s $service_ip" [[ $password != *([[:space:]]) ]] && aOpt=" -A $password" print -- "$0()[$LINENO]($SECONDS): $HACSPOC/cl_change_efs$mOpt$vOpt$sOpt$aOpt" >>$CLMGR_TMPLOG # Always log commands $HACSPOC/cl_change_efs$mOpt$vOpt$sOpt$aOpt rc=$? print "$0()[$LINENO]($SECONDS): cl_change_efs RC: $rc" >>$CLMGR_TMPLOG # Always log command result if (( $rc != RC_SUCCESS )); then /usr/bin/dspmsg -s $CLMGR_SET $CLMGR_MSGS 400 "\nERROR: failed to modify %1\$s.\n\n" EFS 1>&2 rc=$RC_ERROR #=========================================================== : If output from this operation was requested, retrieve it #=========================================================== else if (( CLMGR_VERBOSE )) || [[ -n $CLMGR_ATTRS ]]; then CL=$LINENO KLIB_HACMP_get_efs_attributes properties fi fi fi #======================================================================= : If a user input error was detected, provide some helpful suggestions #======================================================================= if (( $rc == RC_MISSING_INPUT || $rc == RC_INCORRECT_INPUT )) && \ [[ $CLMGR_GUI == *([[:space:]]) ]] then CL=$LINENO cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 104 "For more information about available options and syntax, try\n\"$HAUTILS/clmgr %1\$s\". As an\nalternative, if the PowerHA SystemMirror man pages have been installed, invoke\n\"$HAUTILS/clmgr -hv\" (or \"/usr/bin/man clmgr\"),\nsearching for \"%2\$s\" in the displayed text.\n\n" \ "modify efs -h" "EFS:" "$CLMGR_PROGNAME" 1>&2 fi log_return_msg "$rc" "$0()" "$LINENO" return $? } # End of "KLIB_HACMP_modify_efs()"