#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2017,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/usr/sbin/cluster/events/utils/cl_activate_nfs.sh 1.19.4.2 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 1990,2015 # 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 # @(#) 7d4c34b 43haes/usr/sbin/cluster/events/utils/cl_activate_nfs.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM # # COMPONENT_NAME: EVENTUTILS # # FUNCTIONS: nfs_mount # # ORIGINS: 27 # # # (C) COPYRIGHT International Business Machines Corp. 1990,1994 # All Rights Reserved # Licensed Materials - Property of IBM # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # ############################################################################### # # Name: cl_activate_nfs # # This function will NFS mount the specified filesystems. # # We background the mounts instead of specifying the bg option to the mount # command because the standard mount command will fail if the server host is # not ready (i.e. has not exported the filesystem). This command will retry # in the background. # # Note that this route assumes the filesystem is already mounted if any # mounted filesystem has a matching name. # # Returns: # 0 - All filesystems passed were either mounted or mounts # were scheduled in the background # 1 - One or more filesystems failed to mount # 2 - Zero arguments were passed # # Argument: Number of retries, NFS_server_host, list of filesystems to activate # # Environment: VERBOSE_LOGGING, PATH # ############################################################################### # Including Availability metrics library file . /usr/es/lib/ksh93/availability/cl_amlib PROGNAME=${0##*/} [[ "$VERBOSE_LOGGING" == "high" ]] && set -x [[ "$VERBOSE_LOGGING" == "high" ]] && version='1.19.4.2 $Source$' . /usr/es/sbin/cluster/events/utils/cl_nfs_utils set -u ############################################################################### # Name: nfs_mount # Usage: nfs_mount tries host fs mnt # Description: # Try to NFS mount the specified filesystem. # Arguments: # TRIES - number of attempts (sleep 30 seconds between retries) # HOST - NFS server host # FileSystem - filesystem to mount # MountPoint - mount point # Returns: # 0 - success # 1 - hit max retry count without success # 2 - bad arg count # # Environment: # NONE # ############################################################################### function nfs_mount { typeset PS4_TIMER="true" [[ "$VERBOSE_LOGGING" == "high" ]] && set -x if (( $# != 4 )) then cl_echo 17 "usage: $0 tries host filesystem mountpoint\n" $0 return 2 fi # # Pick up passed parameters # integer LIMIT=$1 HOST=$2 FileSystem=$3 MountPoint=$4 # # First, check to see if this one is already mounted # mount | \ while read node node_fs lcl_mount rest do if [[ $lcl_mount == $MountPoint ]] then cl_echo 11 "$PROGNAME: Filesystem $MountPoint already mounted.\n" $PROGNAME $MountPoint return 0 fi done vers= if [[ $VERSION_SOURCE == "ODM" ]] ; then vers=3 for export_v4 in $EXPORT_FILESYSTEM_V4 ; do if [[ "$filesystem" == "$export_v4" ]] ; then vers=4 break fi done fi # # Pick up and, if necessary modify the mount options so that they # reflect the recovery_method processing intent # OPTIONS=$(lsfs -c -v nfs | grep "^${MountPoint}:" | cut -d: -f7) OPTIONS=$(echo $OPTIONS | sed 's/+/:/g') if [[ -z $OPTIONS ]] then # # If there are no mount options specified for this filesystem in # /etc/filesystems, do a hard, interruptable mount # OPTIONS="hard,intr" elif ! print $OPTIONS | grep -q intr then # # If the given options didn't include 'interruptable', make it so # OPTIONS="$OPTIONS,intr" # # Note that if someone explicitly specified 'nointr' in the # /etc/filesystems entry, that's what they're going to get # fi # Add the version information at the beginning so that it will override # version information from lsfs (i.e., /etc/filesystems). # Note: If an option is given twice, mount uses the first occurrence and # ignores the second one. [[ -n "$vers" ]] && OPTIONS="vers=$vers,$OPTIONS" # # If the user specified sequential processing, override any background # option from /etc/filesystems, so that the processing is totally # sequential. # if [[ $METHOD == sequential ]] then OPTIONS=$(print $OPTIONS | sed 's/bg/fg/g') let LIMIT+=4 # allow a few extra tries fi # # Keep trying until the mount succeeds or the retry limit is reached # typeset RC # Format for consumption by cl_am utility amlog_trace $AM_NFS_ACTIVATE_BEGIN "Activating NFS|$FileSystem" for (( TRIES=0 ; TRIES