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. 2005,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 | # @(#)21 1.10.1.3 src/avs/fs/mmfs/ts/admin/mmmount.sh, mmfs, avs_rgpfs24, rgpfs24s007a 10/5/06 17:58:00 |
---|
17 | ############################################################################## |
---|
18 | # |
---|
19 | # Mount GPFS file systems on one or more nodes in the cluster. |
---|
20 | # |
---|
21 | # Usage: |
---|
22 | # mmmount {Device | DefaultMountPoint | all} [-o MountOptions] |
---|
23 | # [-a | -N {Node[,Node...] | NodeFile | NodeClass}] |
---|
24 | # or |
---|
25 | # mmmount Device MountPoint [-o MountOptions] |
---|
26 | # [-a | -N {Node[,Node...] | NodeFile | NodeClass}] |
---|
27 | # |
---|
28 | # where: |
---|
29 | # -a Mount the file systems on all nodes in the cluster. |
---|
30 | # |
---|
31 | # -N Node,Node,... Specify the nodes on which the mount is to take place. |
---|
32 | # -N NodeFile NodeClass may be one of several possible node classes |
---|
33 | # -N NodeClass (e.g., quorumnodes, managernodes, nsdnodes, etc.) |
---|
34 | # |
---|
35 | # -o MountOptions is a comma-separated list of mount options. |
---|
36 | # |
---|
37 | # If not explicitly-specified otherwise, the file systems are mounted on |
---|
38 | # the local node only. |
---|
39 | # |
---|
40 | # |
---|
41 | # Undocumented option: |
---|
42 | # |
---|
43 | # -y Suppress internal remounting. |
---|
44 | # |
---|
45 | ############################################################################## |
---|
46 | |
---|
47 | # Include global declarations and service routines. |
---|
48 | . /usr/lpp/mmfs/bin/mmglobfuncs |
---|
49 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
---|
50 | |
---|
51 | sourceFile="mmmount.sh" |
---|
52 | [[ -n $DEBUG || -n $DEBUGmmmount ]] && set -x |
---|
53 | $mmTRACE_ENTER "$*" |
---|
54 | |
---|
55 | |
---|
56 | # Local variables |
---|
57 | |
---|
58 | usageMsg=390 |
---|
59 | rc=0 |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | ####################### |
---|
64 | # Mainline processing |
---|
65 | ####################### |
---|
66 | |
---|
67 | |
---|
68 | ################################## |
---|
69 | # Process each of the arguments. |
---|
70 | ################################## |
---|
71 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
---|
72 | syntaxError "help" $usageMsg |
---|
73 | |
---|
74 | [[ $argc -lt 1 ]] && \ |
---|
75 | syntaxError "missingArgs" $usageMsg |
---|
76 | |
---|
77 | # Figure out what was specified on the command line. |
---|
78 | if [[ $arg1 = /* && $arg1 != +(/)dev+(/)* ]] |
---|
79 | then |
---|
80 | # If the first argument starts with a "/" but not "/dev/", |
---|
81 | # it is assumed to be a fully-qualified mount point. |
---|
82 | defaultMountPoint=$arg1 |
---|
83 | shift 1 |
---|
84 | |
---|
85 | else |
---|
86 | # Otherwise, the argument is assumed to be the device name |
---|
87 | # of a file system (or one of the "all" the keywords). |
---|
88 | device=$arg1 |
---|
89 | shift 1 |
---|
90 | |
---|
91 | # If a device name was specified, the second argument may be |
---|
92 | # the fully-qualified path name of a mount point to use. |
---|
93 | if [[ -n $arg2 ]] |
---|
94 | then |
---|
95 | if [[ $arg2 = -* ]] |
---|
96 | then |
---|
97 | : # This must be an option; we'll handle it later. |
---|
98 | elif [[ $arg1 = all || $arg1 = all_local || $arg1 = all_remote ]] |
---|
99 | then |
---|
100 | # Mount point cannot be specified when mounting all file systems. |
---|
101 | printErrorMsg 281 $mmcmd |
---|
102 | syntaxError "help" $usageMsg |
---|
103 | elif [[ $arg2 != /* ]] |
---|
104 | then |
---|
105 | # The mount point must be a fully-qualified path name. |
---|
106 | syntaxError "absolutePath" $noUsageMsg "$arg2" |
---|
107 | else |
---|
108 | # The second argument must be a mount pount. |
---|
109 | newMountPoint=$arg2 |
---|
110 | shift 1 |
---|
111 | fi # end of if [[ $arg2 = -* ]] |
---|
112 | fi # end of if [[ -n $arg2 ]] |
---|
113 | fi # end of if [[ $arg1 = "/"* && $arg1 != +(/)dev+(/)* ]] |
---|
114 | |
---|
115 | # Process the rest of the options. |
---|
116 | while getopts :aN:o:y OPT |
---|
117 | do |
---|
118 | case $OPT in |
---|
119 | |
---|
120 | a) [[ -n $aflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
121 | aflag="-$OPT" |
---|
122 | ;; |
---|
123 | |
---|
124 | N) [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
125 | Nflag="-$OPT" |
---|
126 | nodenames="$OPTARG" |
---|
127 | ;; |
---|
128 | |
---|
129 | o) [[ -n $oflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
130 | oflag="-$OPT" |
---|
131 | mountOptions="$OPTARG" |
---|
132 | ;; |
---|
133 | |
---|
134 | y) [[ -n $yflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
135 | yflag="doNotRemount" |
---|
136 | ;; |
---|
137 | |
---|
138 | :) syntaxError "missingValue" $usageMsg $OPTARG |
---|
139 | ;; |
---|
140 | |
---|
141 | +[aNoy]) |
---|
142 | syntaxError "invalidOption" $usageMsg "$OPT" |
---|
143 | ;; |
---|
144 | |
---|
145 | *) syntaxError "invalidOption" $usageMsg $OPTARG |
---|
146 | ;; |
---|
147 | |
---|
148 | esac |
---|
149 | done |
---|
150 | |
---|
151 | shift OPTIND-1 |
---|
152 | [[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1 |
---|
153 | |
---|
154 | [[ -z $mountOptions ]] && mountOptions=DEFAULT |
---|
155 | [[ -z $newMountPoint ]] && newMountPoint=DEFAULT |
---|
156 | |
---|
157 | |
---|
158 | ######################################################################## |
---|
159 | # Set up trap exception handling and call the gpfsInit function. |
---|
160 | # It will ensure that the local copy of the mmsdrfs and the rest of the |
---|
161 | # GPFS system files are up-to-date. There is no need to lock the sdr. |
---|
162 | ######################################################################## |
---|
163 | trap pretrap2 HUP INT QUIT KILL |
---|
164 | gpfsInitOutput=$(gpfsInit nolock) |
---|
165 | setGlobalVar $? $gpfsInitOutput |
---|
166 | |
---|
167 | |
---|
168 | ####################################################### |
---|
169 | # Create a file containing all of the specified nodes. |
---|
170 | ####################################################### |
---|
171 | if [[ -n $aflag ]] |
---|
172 | then |
---|
173 | # Get a list of the nodes. |
---|
174 | getNodeList $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile > $nodefile |
---|
175 | |
---|
176 | elif [[ -n $Nflag ]] |
---|
177 | then |
---|
178 | # Convert the passed data into a file containing admin node names. |
---|
179 | createVerifiedNodefile "$nodenames" $REL_HOSTNAME_Field no $nodefile |
---|
180 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
181 | |
---|
182 | else |
---|
183 | : # Nothing to do. Only the local node is affected. |
---|
184 | fi # end of if [[ -n $aflag ]] |
---|
185 | |
---|
186 | |
---|
187 | ################################# |
---|
188 | # Verify the file system exists. |
---|
189 | ################################# |
---|
190 | if [[ $device = all || $device = all_local || $device = all_remote ]] |
---|
191 | then |
---|
192 | # Ensure there is at least one file systems to mount. |
---|
193 | $awk -F: ' \ |
---|
194 | BEGIN { rc = '$MM_FsNotFound' } \ |
---|
195 | $'$LINE_TYPE_Field' == "'$SG_HEADR'" { \ |
---|
196 | if ( device == "all" || \ |
---|
197 | device == "all_local" && $'$FS_TYPE_Field' == "'$localfs'" || \ |
---|
198 | device == "all_remote" && $'$FS_TYPE_Field' == "'$remotefs'" ) { \ |
---|
199 | { rc = 0 } \ |
---|
200 | { exit } \ |
---|
201 | } \ |
---|
202 | } \ |
---|
203 | END { exit rc } \ |
---|
204 | ' device=$device $mmsdrfsFile |
---|
205 | rc=$? |
---|
206 | |
---|
207 | if [[ $rc = $MM_FsNotFound ]] |
---|
208 | then |
---|
209 | # No file systems were found in the cluster. |
---|
210 | if [[ $device = all || $device = all_local ]] |
---|
211 | then |
---|
212 | printErrorMsg 200 $mmcmd |
---|
213 | else |
---|
214 | printErrorMsg 193 $mmcmd |
---|
215 | fi |
---|
216 | cleanupAndExit $rc |
---|
217 | else |
---|
218 | # Check for unexpected errors |
---|
219 | checkForErrors awk $rc |
---|
220 | fi # end of if [[ $rc = $MM_FsNotFound ]] |
---|
221 | |
---|
222 | deviceName=$device |
---|
223 | defaultOptions=DEFAULT |
---|
224 | |
---|
225 | else |
---|
226 | # Look for the file system either by device name or by mount point. |
---|
227 | if [[ -n $device ]] |
---|
228 | then |
---|
229 | findFSoutput=$(findFS "$device" $mmsdrfsFile device) |
---|
230 | else |
---|
231 | findFSoutput=$(findFS "$defaultMountPoint" $mmsdrfsFile mountPoint) |
---|
232 | fi |
---|
233 | [[ -z $findFSoutput ]] && cleanupAndExit |
---|
234 | |
---|
235 | # Parse the output from the findFS function. |
---|
236 | set -f ; set -- $findFSoutput ; set +f |
---|
237 | fqDeviceName=$1 |
---|
238 | deviceName=$2 |
---|
239 | fsHomeCluster=$3 |
---|
240 | defaultMountPoint=$6 |
---|
241 | defaultOptions=$7 |
---|
242 | fi # end of if [[ $device = all || ... |
---|
243 | |
---|
244 | # Ensure we have the proper credentials. |
---|
245 | [[ $getCredCalled = no ]] && getCred |
---|
246 | |
---|
247 | |
---|
248 | ################################################# |
---|
249 | # Mount the file systems on the specified nodes. |
---|
250 | ################################################# |
---|
251 | |
---|
252 | # Mounting file systems ... |
---|
253 | printInfoMsg 373 "$(date)" $mmcmd |
---|
254 | |
---|
255 | if [[ ! -s $nodefile ]] |
---|
256 | then |
---|
257 | # The request is to mount file systems on the local node only. |
---|
258 | $mmremote mountFileSystems \ |
---|
259 | $deviceName "$newMountPoint" "$defaultOptions" "$mountOptions" $yflag |
---|
260 | rc=$? |
---|
261 | else |
---|
262 | # The request is to mount file systems on a number of nodes. |
---|
263 | # Note: The two option strings may contain a semi-colon |
---|
264 | # and must be double-quoted. |
---|
265 | $mmcommon onall $nodefile $unreachedNodes mountFileSystems \ |
---|
266 | $deviceName "$newMountPoint" "\"$defaultOptions\"" "\"$mountOptions\"" $yflag |
---|
267 | rc=$? |
---|
268 | fi |
---|
269 | |
---|
270 | # If any nodes could not be reached, tell the user which ones. |
---|
271 | if [[ -s $unreachedNodes ]] |
---|
272 | then |
---|
273 | # The following nodes could not be reached: . . . |
---|
274 | printErrorMsg 270 $mmcmd |
---|
275 | $cat $unreachedNodes 1>&2 |
---|
276 | fi |
---|
277 | |
---|
278 | cleanupAndExit $rc |
---|
279 | |
---|