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. 1999,2005 |
---|
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 | # @(#)79 1.28 src/avs/fs/mmfs/ts/admin/mmchmgr.sh, mmfs, avs_rgpfs24, rgpfs240610b 6/20/05 12:50:49 |
---|
17 | ####################################################################### |
---|
18 | # |
---|
19 | # Usage: mmchmgr Device [ToNode] |
---|
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="mmchmgr.sh" |
---|
29 | [[ -n $DEBUG || -n $DEBUGmmchmgr ]] && set -x |
---|
30 | $mmTRACE_ENTER "$*" |
---|
31 | |
---|
32 | # Local variables |
---|
33 | usageMsg=304 |
---|
34 | integer rc=0 |
---|
35 | integer nodeCount=0 |
---|
36 | |
---|
37 | |
---|
38 | ##################################################################### |
---|
39 | # Process the command arguments. |
---|
40 | # The detailed syntax checking is left for the ts command. |
---|
41 | # Here we make sure that we have the minimum needed to continue. |
---|
42 | ##################################################################### |
---|
43 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
---|
44 | syntaxError "help" $usageMsg |
---|
45 | |
---|
46 | [[ $argc -lt 1 ]] && \ |
---|
47 | syntaxError "missingArgs" $usageMsg |
---|
48 | |
---|
49 | device=$arg1 # Save stripe group device (always the first parameter). |
---|
50 | shift 1 # Drop the device name from the parameter list. |
---|
51 | argList=$@ # Save the remainder of the argument list. |
---|
52 | |
---|
53 | |
---|
54 | ######################################################################## |
---|
55 | # Set up trap exception handling and call the gpfsInit function. |
---|
56 | # It will ensure that the local copy of the mmsdrfs and the rest of the |
---|
57 | # GPFS system files are up-to-date. There is no need to lock the sdr. |
---|
58 | ######################################################################## |
---|
59 | trap pretrap2 HUP INT QUIT KILL |
---|
60 | gpfsInitOutput=$(gpfsInit nolock) |
---|
61 | setGlobalVar $? $gpfsInitOutput |
---|
62 | |
---|
63 | if [[ $MMMODE = single ]] |
---|
64 | then |
---|
65 | # Command currently not valid for cluster type single. |
---|
66 | printErrorMsg 376 $mmcmd single |
---|
67 | cleanupAndExit |
---|
68 | fi |
---|
69 | |
---|
70 | |
---|
71 | ########################################################### |
---|
72 | # Make sure the specified file system exists and is local. |
---|
73 | ########################################################### |
---|
74 | findFSoutput=$(findFS "$device" $mmsdrfsFile) |
---|
75 | [[ -z $findFSoutput ]] && cleanupAndExit |
---|
76 | |
---|
77 | # Parse the output from the findFS function. |
---|
78 | set -f ; set -- $findFSoutput ; set +f |
---|
79 | fqDeviceName=$1 |
---|
80 | deviceName=$2 |
---|
81 | fsHomeCluster=$3 |
---|
82 | |
---|
83 | # Exit with a message if the command was invoked for a remote file system. |
---|
84 | if [[ $fsHomeCluster != $HOME_CLUSTER ]] |
---|
85 | then |
---|
86 | # Command is not allowed for remote file systems. |
---|
87 | printErrorMsg 106 $mmcmd $device $fsHomeCluster |
---|
88 | cleanupAndExit |
---|
89 | fi |
---|
90 | |
---|
91 | |
---|
92 | ########################################################### |
---|
93 | # If a node was specified, make sure that it is valid |
---|
94 | # and convert it if necessary to a daemon node name. |
---|
95 | ########################################################### |
---|
96 | if [[ -n $argList ]] |
---|
97 | then |
---|
98 | nodeName=$(checkAndConvertNodeValue $argList $DAEMON_NODENAME_Field) |
---|
99 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
100 | argList=$nodeName |
---|
101 | fi # end of if [[ -n $argList ]] |
---|
102 | |
---|
103 | |
---|
104 | ########################################################## |
---|
105 | # If the cluster to which this node belongs is the same |
---|
106 | # as the cluster in which the file system resides, |
---|
107 | # invoke the command directly. |
---|
108 | ########################################################## |
---|
109 | if [[ $nsId = $fsHomeCluster ]] |
---|
110 | then |
---|
111 | ${mmcmdDir}/${links}/mmchmgr $fqDeviceName $argList 2>$errMsg |
---|
112 | rc=$(remapRC $?) |
---|
113 | |
---|
114 | # If the command completed successfully, or if there is an |
---|
115 | # unacceptable error, display any error messages and get out. |
---|
116 | if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ]] |
---|
117 | then |
---|
118 | [[ -s $errMsg ]] && $cat $errMsg 1>&2 |
---|
119 | if [[ $rc -eq $MM_ConnectionReset ]] |
---|
120 | then |
---|
121 | # An internode connection was reset. |
---|
122 | printErrorMsg 257 $mmcmd |
---|
123 | fi |
---|
124 | cleanupAndExit $rc |
---|
125 | fi |
---|
126 | fi |
---|
127 | $rm -f $errMsg |
---|
128 | |
---|
129 | |
---|
130 | ################################################### |
---|
131 | # If the local daemon is not available, |
---|
132 | # find an active node and send the command there. |
---|
133 | ################################################### |
---|
134 | |
---|
135 | # Create a file with the reliable names that form |
---|
136 | # the cluster to which the file system belongs. |
---|
137 | nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile) |
---|
138 | if [[ $nodeCount -eq 0 ]] |
---|
139 | then |
---|
140 | # The cluster is empty; there is nobody to run the command. |
---|
141 | printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1 |
---|
142 | cleanupAndExit |
---|
143 | fi |
---|
144 | |
---|
145 | # Try the nodes one by one until you find a node that can execute the command. |
---|
146 | preferredNode=0 # We have no idea where to go first; let mmcommon decide. |
---|
147 | $mmcommon linkCommand $preferredNode $nodefile mmchmgr $fqDeviceName $argList |
---|
148 | rc=$? |
---|
149 | |
---|
150 | cleanupAndExit $rc |
---|
151 | |
---|