| [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. 2001,2004 |
|---|
| 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 | # @(#)73 1.13 src/avs/fs/mmfs/ts/admin/mmrestorefs.sh, mmfs, avs_rgpfs24, rgpfs240610b 11/15/04 02:35:50 |
|---|
| 17 | ####################################################################### |
|---|
| 18 | # |
|---|
| 19 | # Usage: mmrestorefs Device Directory |
|---|
| 20 | # |
|---|
| 21 | ####################################################################### |
|---|
| 22 | |
|---|
| 23 | # Include global declarations and service routines |
|---|
| 24 | . /usr/lpp/mmfs/bin/mmglobfuncs |
|---|
| 25 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
|---|
| 26 | . /usr/lpp/mmfs/bin/mmfsfuncs |
|---|
| 27 | |
|---|
| 28 | sourceFile="mmrestorefs.sh" |
|---|
| 29 | [[ -n $DEBUG || -n $DEBUGmmrestorefs ]] && set -x |
|---|
| 30 | $mmTRACE_ENTER "$*" |
|---|
| 31 | |
|---|
| 32 | usageMsg=419 |
|---|
| 33 | integer rc=0 |
|---|
| 34 | integer nodeCount=0 |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | ##################################################################### |
|---|
| 38 | # Process the command arguments. |
|---|
| 39 | # The detailed syntax checking is left for the ts command. |
|---|
| 40 | # Here we make sure that we have the minimum needed to continue. |
|---|
| 41 | ##################################################################### |
|---|
| 42 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
|---|
| 43 | syntaxError "help" $usageMsg |
|---|
| 44 | |
|---|
| 45 | [[ $argc -lt 1 ]] && \ |
|---|
| 46 | syntaxError "missingArgs" $usageMsg |
|---|
| 47 | |
|---|
| 48 | device=$arg1 # Save stripe group device (always the first parameter). |
|---|
| 49 | shift 1 # Drop the device name from the parameter list. |
|---|
| 50 | argList=$@ # Save the remainder of the argument list. |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | ##################################################################### |
|---|
| 54 | # Set up trap exception handling and ensure that the local copy of |
|---|
| 55 | # the mmsdrfs is up-to-date. There is no need to lock mmsdrfs file. |
|---|
| 56 | ##################################################################### |
|---|
| 57 | trap pretrap2 HUP INT QUIT KILL |
|---|
| 58 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 59 | setGlobalVar $? $gpfsInitOutput |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | ########################################################### |
|---|
| 63 | # Make sure the specified file system exists and is local. |
|---|
| 64 | ########################################################### |
|---|
| 65 | findFSoutput=$(findFS "$device" $mmsdrfsFile) |
|---|
| 66 | [[ -z $findFSoutput ]] && cleanupAndExit |
|---|
| 67 | |
|---|
| 68 | # Parse the output from the findFS function. |
|---|
| 69 | set -f ; set -- $findFSoutput ; set +f |
|---|
| 70 | fqDeviceName=$1 |
|---|
| 71 | deviceName=$2 |
|---|
| 72 | fsHomeCluster=$3 |
|---|
| 73 | |
|---|
| 74 | # Exit with a message if the command was invoked for a remote file system. |
|---|
| 75 | if [[ $fsHomeCluster != $HOME_CLUSTER ]] |
|---|
| 76 | then |
|---|
| 77 | # Command is not allowed for remote file systems. |
|---|
| 78 | printErrorMsg 106 $mmcmd $device $fsHomeCluster |
|---|
| 79 | cleanupAndExit 1 |
|---|
| 80 | fi |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | ########################################################## |
|---|
| 84 | # If the cluster to which this node belongs is the same |
|---|
| 85 | # as the cluster in which the file system resides, |
|---|
| 86 | # invoke the command directly. |
|---|
| 87 | ########################################################## |
|---|
| 88 | if [[ $nsId = $fsHomeCluster ]] |
|---|
| 89 | then |
|---|
| 90 | ${mmcmdDir}/${links}/mmrestorefs $fqDeviceName $argList 2>$errMsg |
|---|
| 91 | rc=$(remapRC $?) |
|---|
| 92 | |
|---|
| 93 | # If the command completed successfully, or if there is an |
|---|
| 94 | # unacceptable error, display any error messages and get out. |
|---|
| 95 | if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ]] |
|---|
| 96 | then |
|---|
| 97 | [[ -s $errMsg ]] && $cat $errMsg 1>&2 |
|---|
| 98 | if [[ $rc -eq $MM_ConnectionReset ]] |
|---|
| 99 | then |
|---|
| 100 | # An internode connection was reset. |
|---|
| 101 | printErrorMsg 257 $mmcmd |
|---|
| 102 | fi |
|---|
| 103 | cleanupAndExit $rc |
|---|
| 104 | fi |
|---|
| 105 | fi |
|---|
| 106 | $rm -f $errMsg |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | ############################################################################ |
|---|
| 110 | # If the local daemon is not available, send the command to an active node. |
|---|
| 111 | ############################################################################ |
|---|
| 112 | |
|---|
| 113 | # Create a file with the reliable names that form the |
|---|
| 114 | # cluster to which the file system belongs. |
|---|
| 115 | nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile) |
|---|
| 116 | if [[ $nodeCount -eq 0 ]] |
|---|
| 117 | then |
|---|
| 118 | # The cluster is empty; there is nobody to run the command. |
|---|
| 119 | printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1 |
|---|
| 120 | cleanupAndExit |
|---|
| 121 | fi |
|---|
| 122 | |
|---|
| 123 | # Try the nodes one by one until you find a node that can execute the command. |
|---|
| 124 | preferredNode=0 # We have no idea where to go first; let mmcommon decide. |
|---|
| 125 | $mmcommon linkCommand $preferredNode $nodefile mmrestorefs $fqDeviceName $argList |
|---|
| 126 | rc=$? |
|---|
| 127 | |
|---|
| 128 | cleanupAndExit $rc |
|---|
| 129 | |
|---|