| [16] | 1 | #!/bin/ksh | 
|---|
 | 2 | # IBM_PROLOG_BEGIN_TAG  | 
|---|
 | 3 | # This is an automatically generated prolog.  | 
|---|
 | 4 | #   | 
|---|
 | 5 | #   | 
|---|
 | 6 | #   | 
|---|
 | 7 | # Licensed Materials - Property of IBM  | 
|---|
 | 8 | #   | 
|---|
 | 9 | # (C) COPYRIGHT International Business Machines Corp. 1997,2006  | 
|---|
 | 10 | # All Rights Reserved  | 
|---|
 | 11 | #   | 
|---|
 | 12 | # US Government Users Restricted Rights - Use, duplication or  | 
|---|
 | 13 | # disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  | 
|---|
 | 14 | #   | 
|---|
 | 15 | # IBM_PROLOG_END_TAG  | 
|---|
 | 16 | # @(#)01 1.57.1.1 src/avs/fs/mmfs/ts/admin/mmautoload.sh, mmfs, avs_rgpfs24, rgpfs24s001a 4/5/06 11:34:58 | 
|---|
 | 17 | ######################################################################### | 
|---|
 | 18 | #                                                                       # | 
|---|
 | 19 | #  Usage:  mmautoload                                                   # | 
|---|
 | 20 | #                                                                       # | 
|---|
 | 21 | #  Called once from inittab.  Performs GPFS configuration               # | 
|---|
 | 22 | #  initialization.  If everything goes smoothly, and the                # | 
|---|
 | 23 | #  autoload parameter is set to yes, starts the GPFS daemon.            # | 
|---|
 | 24 | #                                                                       # | 
|---|
 | 25 | ######################################################################### | 
|---|
 | 26 |  | 
|---|
 | 27 | # Include global declarations and service routines. | 
|---|
 | 28 | . /usr/lpp/mmfs/bin/mmglobfuncs | 
|---|
 | 29 | . /usr/lpp/mmfs/bin/mmsdrfsdef | 
|---|
 | 30 | . /usr/lpp/mmfs/bin/mmfsfuncs | 
|---|
 | 31 |  | 
|---|
 | 32 | sourceFile="mmautoload.sh" | 
|---|
 | 33 | [[ -n $DEBUG || -n $DEBUGmmautoload ]] && set -x | 
|---|
 | 34 | $mmTRACE_ENTER "$*" | 
|---|
 | 35 |  | 
|---|
 | 36 | # Local variables | 
|---|
 | 37 |  | 
|---|
 | 38 | mmfslog=${rasDir}mmfs.log.latest # daemon log (/var/adm/ras/mmfs.log.latest) | 
|---|
 | 39 | interval=10                      # 10 6-second intervals is a message per minute | 
|---|
 | 40 | integer waitPeriod               # wait period (in minutes) | 
|---|
 | 41 | integer timeout | 
|---|
 | 42 |  | 
|---|
 | 43 |  | 
|---|
 | 44 | ########################################################### | 
|---|
 | 45 | # | 
|---|
 | 46 | #  Mainline processing | 
|---|
 | 47 | # | 
|---|
 | 48 | ########################################################### | 
|---|
 | 49 |  | 
|---|
 | 50 | # If the node does not appear to belong to a GPFS cluster, | 
|---|
 | 51 | # go away quietly. | 
|---|
 | 52 | if [[ ! -f $mmsdrfsFile ]] | 
|---|
 | 53 | then | 
|---|
 | 54 |   $rm -f $GLOBAL_FILES $LOCAL_FILES | 
|---|
 | 55 |   return 0 | 
|---|
 | 56 | fi | 
|---|
 | 57 |  | 
|---|
 | 58 | # Determine the type of cluster environment. | 
|---|
 | 59 | determineMode | 
|---|
 | 60 |  | 
|---|
 | 61 | # If the cluster type is not known, go away quietly. | 
|---|
 | 62 | if [[ $MMMODE != lc && $MMMODE != single ]] | 
|---|
 | 63 | then | 
|---|
 | 64 |   $rm -f $GLOBAL_FILES $LOCAL_FILES | 
|---|
 | 65 |   return 0 | 
|---|
 | 66 | fi | 
|---|
 | 67 |  | 
|---|
 | 68 | # Put a message in the daemon log to reflect the node reboot. | 
|---|
 | 69 | [[ -f $mmfslog ]] &&  \ | 
|---|
 | 70 |   print "\n\n$(date): Node rebooted.  Starting mmautoload..." >> $mmfslog | 
|---|
 | 71 |  | 
|---|
 | 72 | # Force the recreation of the local system files. | 
|---|
 | 73 | $rm -f $mmfsNodeData $mmfscfgFile ${mmfsNewKeyLevel}+([0-9])  \ | 
|---|
 | 74 |        ${mmfsCommittedKeyLevel}+([0-9]) $nsdpvol | 
|---|
 | 75 |  | 
|---|
 | 76 | # If AIX, verify there is an mmfs entry in /etc/vfs. | 
|---|
 | 77 | # If Linux, figure out what is the correct major number. | 
|---|
 | 78 | checkVfsNumber | 
|---|
 | 79 | rc=$? | 
|---|
 | 80 | if [[ $rc -ne 0 ]] | 
|---|
 | 81 | then | 
|---|
 | 82 |   $rm -f $GLOBAL_FILES $LOCAL_FILES | 
|---|
 | 83 |   return 0 | 
|---|
 | 84 | fi | 
|---|
 | 85 |  | 
|---|
 | 86 | # Verify that the GPFS environment is properly initialized. | 
|---|
 | 87 | # If not successful, keep trying for up to 5 minutes before giving up. | 
|---|
 | 88 | waitPeriod=5 | 
|---|
 | 89 | timeout=1 | 
|---|
 | 90 | $rm -f $errMsg | 
|---|
 | 91 | while true | 
|---|
 | 92 | do | 
|---|
 | 93 |   export MOUNT_POINT_CHECK=all | 
|---|
 | 94 |   gpfsInitOutput=$(gpfsInit nolock 2>$errMsg) | 
|---|
 | 95 |   rc=$? | 
|---|
 | 96 |   unset MOUNT_POINT_CHECK | 
|---|
 | 97 |   if [[ $rc -ne 0 || -z $gpfsInitOutput ]] | 
|---|
 | 98 |   then | 
|---|
 | 99 |     # gpfsInit failed but there still may be a chance | 
|---|
 | 100 |     # for things to get fixed - we'll try again. | 
|---|
 | 101 |     whatfor="cluster data repository" | 
|---|
 | 102 |   else | 
|---|
 | 103 |     # The gpfsInit call worked. | 
|---|
 | 104 |     # Parse the result and get out of the loop. | 
|---|
 | 105 |     setGlobalVar 0 $gpfsInitOutput | 
|---|
 | 106 |     $rm -f $errMsg | 
|---|
 | 107 |     break | 
|---|
 | 108 |   fi  # end of if [[ $rc -ne 0 || -z $gpfsInitOutput ]] | 
|---|
 | 109 |  | 
|---|
 | 110 |   # Something is not right.  Put out a message every 60 seconds. | 
|---|
 | 111 |   timeout=timeout-1 | 
|---|
 | 112 |   if [[ $timeout -le 0 ]] | 
|---|
 | 113 |   then | 
|---|
 | 114 |     # Show detailed error messages if any. | 
|---|
 | 115 |     [[ -s $errMsg ]] && $cat $errMsg 1>&2 | 
|---|
 | 116 |     # Tell what it is that we are waiting for. | 
|---|
 | 117 |     printErrorMsg 142 $mmcmd "$whatfor" | 
|---|
 | 118 |     # Put the messages in the daemon log as well. | 
|---|
 | 119 |     if [[ -f $mmfslog ]] | 
|---|
 | 120 |     then | 
|---|
 | 121 |       [[ -s $errMsg ]] && $cat $errMsg     >> $mmfslog | 
|---|
 | 122 |       printErrorMsg 142 $mmcmd "$whatfor" 2>> $mmfslog | 
|---|
 | 123 |     fi | 
|---|
 | 124 |     $rm -f $errMsg | 
|---|
 | 125 |  | 
|---|
 | 126 |     # Reset the counters and see if it is time to give up. | 
|---|
 | 127 |     if [[ $waitPeriod -gt 0 ]] | 
|---|
 | 128 |     then | 
|---|
 | 129 |       waitPeriod=waitPeriod-1 | 
|---|
 | 130 |       timeout=$interval | 
|---|
 | 131 |     else | 
|---|
 | 132 |       # The problem did not clear in the last 5 minutes. | 
|---|
 | 133 |       # Tell the guy to use mmstartup and give up. | 
|---|
 | 134 |       print -u2 "mmautoload: The GPFS environment cannot be initialized." | 
|---|
 | 135 |       print -u2 "mmautoload: Correct the problem and use mmstartup to start GPFS." | 
|---|
 | 136 |       # Put the messages in the daemon log as well. | 
|---|
 | 137 |       if [[ -f $mmfslog ]] | 
|---|
 | 138 |       then | 
|---|
 | 139 |         print "mmautoload: The GPFS environment cannot be initialized." >> $mmfslog | 
|---|
 | 140 |         print "mmautoload: Correct the problem and use mmstartup to start GPFS." >> $mmfslog | 
|---|
 | 141 |       fi | 
|---|
 | 142 |       $rm -f $GLOBAL_FILES $LOCAL_FILES | 
|---|
 | 143 |       return 0 | 
|---|
 | 144 |     fi  # end of if [[ $waitPeriod -gt 0 ]] | 
|---|
 | 145 |   fi  # end of if [[ $timeout -le 0 ]] | 
|---|
 | 146 |   $rm -f $errMsg | 
|---|
 | 147 |  | 
|---|
 | 148 |   # Wait a while before retrying. | 
|---|
 | 149 |   $sleep 6 | 
|---|
 | 150 | done  # end while true | 
|---|
 | 151 |  | 
|---|
 | 152 |  | 
|---|
 | 153 | # If this is a primary or backup config server, | 
|---|
 | 154 | # ensure the mmsdrserv daemon is running. | 
|---|
 | 155 | if [[ $ourNodeName = $primaryServer || $ourNodeName = $backupServer ]] | 
|---|
 | 156 | then | 
|---|
 | 157 |   startSdrServ CURRENT 2>$errMsg | 
|---|
 | 158 |  | 
|---|
 | 159 |   # Show detailed error messages if any. | 
|---|
 | 160 |   if [[ -s $errMsg ]] | 
|---|
 | 161 |   then | 
|---|
 | 162 |     $cat $errMsg 1>&2 | 
|---|
 | 163 |     [[ -f $mmfslog ]] && $cat $errMsg >> $mmfslog | 
|---|
 | 164 |   fi | 
|---|
 | 165 |   $rm -f $errMsg | 
|---|
 | 166 | fi  # end of if [[ $ourNodeName = $primaryServer || $ourNodeName = $backupServer ]] | 
|---|
 | 167 |  | 
|---|
 | 168 |  | 
|---|
 | 169 | # Find the setting of the autoload parameter. | 
|---|
 | 170 | autoload=$(showCfgValue autoload) | 
|---|
 | 171 |  | 
|---|
 | 172 |  | 
|---|
 | 173 | # Go away if the autoload parameter is not set to yes. | 
|---|
 | 174 | if [[ $autoload != yes ]] | 
|---|
 | 175 | then | 
|---|
 | 176 |   $rm -f $GLOBAL_FILES $LOCAL_FILES | 
|---|
 | 177 |   return 0 | 
|---|
 | 178 | fi | 
|---|
 | 179 |  | 
|---|
 | 180 |  | 
|---|
 | 181 | # Start GPFS. | 
|---|
 | 182 | [[ -f $mmfslog ]] &&  \ | 
|---|
 | 183 |   print "\n$(date): mmautoload: Starting GPFS..." >> $mmfslog | 
|---|
 | 184 |  | 
|---|
 | 185 | # Check whether we are already running. | 
|---|
 | 186 | pid=$($ps -eo "pid args" |  \ | 
|---|
 | 187 |       $awk '/\/runmmfs/ && !/this process/ {print $1}') | 
|---|
 | 188 | if [[ -n $pid ]] | 
|---|
 | 189 | then | 
|---|
 | 190 |   # GPFS is already active. | 
|---|
 | 191 |   printInfoMsg 586 GPFS | 
|---|
 | 192 |   [[ -f $mmfslog ]] &&  \ | 
|---|
 | 193 |     printInfoMsg 586 GPFS >> $mmfslog | 
|---|
 | 194 | else | 
|---|
 | 195 |   # Start the daemon. | 
|---|
 | 196 |   # In non-Linux systems, pass the output of gpfsInit | 
|---|
 | 197 |   # to runmmfs to avoid a second initialization call. | 
|---|
 | 198 |   # In Linux, this is not done because the device major | 
|---|
 | 199 |   # number is not available at this time. | 
|---|
 | 200 |   if [[ $osName = Linux ]] | 
|---|
 | 201 |   then | 
|---|
 | 202 |     $daemonize -c $runmmfs | 
|---|
 | 203 |   else | 
|---|
 | 204 |     $daemonize -e "GPFSINIT=\"$gpfsInitOutput\"" -c $runmmfs | 
|---|
 | 205 |   fi | 
|---|
 | 206 | fi | 
|---|
 | 207 |  | 
|---|
 | 208 | $rm -f $GLOBAL_FILES $LOCAL_FILES | 
|---|
 | 209 | return 0 | 
|---|
 | 210 |  | 
|---|