source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmrefresh @ 152

Last change on this file since 152 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 8.4 KB
Line 
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. 2000,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# @(#)71 1.27 src/avs/fs/mmfs/ts/admin/mmrefresh.sh, mmfs, avs_rgpfs24, rgpfs240610b 6/27/05 03:02:52
17##############################################################################
18#
19#  Ensure that the GPFS system files on the specified nodes are at the most
20#  recent level.  If the -f (force) option is specified, rebuild the files
21#  even if they appear to be at the latest level.
22#
23#  Usage:
24#
25#    mmrefresh [-f] [-a | -N {Node[,Node...] | NodeFile | NodeClass}]
26#
27#  where:
28#
29#    -f            Rebuild the GPFS system files even if they appear
30#                  to be at the most current level.
31#
32#    -a            Check all nodes in the GPFS cluster.
33#
34#    -N Node,Node,...  Specify the nodes whose state is desired.
35#    -N NodeFile       NodeClass may be one of several possible node classes
36#    -N NodeClass      (e.g., quorumnodes, managernodes, nsdnodes, etc.)
37#
38#
39#  If not explicitly specified otherwise, only the local node is checked.
40#
41#
42#  Obsolete options:
43#
44#   -C NodesetId  Check all nodes in the specified nodeset.
45#                 Assumed to be the same as -a.
46#
47#   -W NodeFile   Check all nodes whose reliable hostnames
48#                 are listed one per line in NodeFilename.
49#                 Cannot be specified with -a, -N, -w, or -n.
50#
51#   -w nodenames  Check all nodes whose reliable hostnames
52#                 are in the comma-separated nodenames list.
53#                 Cannot be specified with -a, -N or -W.
54#                 If both -w and -n are specified, the lists are combined.
55#
56#   -n nodenums   Check all nodes whose node numbers are
57#                 in the comma-separated nodenums list.
58#                 Cannot be specified with -a, -N, or -W.
59#                 If both -w and -n are specified, the lists are combined.
60#
61##############################################################################
62
63# Include global declarations and service routines.
64. /usr/lpp/mmfs/bin/mmglobfuncs
65. /usr/lpp/mmfs/bin/mmsdrfsdef
66. /usr/lpp/mmfs/bin/mmfsfuncs
67
68sourceFile="mmrefresh.sh"
69[[ -n $DEBUG || -n $DEBUGmmrefresh ]] && set -x
70$mmTRACE_ENTER "$*"
71
72
73# Local variables
74
75usageMsg=374
76typeset -i nodes=0
77rc=0
78nodenames=""
79nodenums=""
80Wcoll=""
81fflag=""
82aflag=""
83Cflag=""
84nflag=""
85Nflag=""
86Wflag=""
87wflag=""
88integer nodeCount=0
89
90
91
92#######################
93# Mainline processing
94#######################
95
96
97##################################
98# Process each of the arguments.
99##################################
100[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
101  syntaxError "help" $usageMsg
102
103while getopts :aC:fn:N:w:W: OPT
104do
105  case $OPT in
106
107    a) [[ -n $aflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
108       aflag="-$OPT"
109       all="all"
110       [[ -n $Cflag || -n $Wflag || -n $wflag || -n $nflag || -n $Nflag ]] &&  \
111         syntaxError "invalidCombination"  \
112           $usageMsg $aflag $Cflag $Wflag $wflag $nflag $Nflag
113       ;;
114
115    C) # syntaxError "obsoleteOption" $usageMsg "-$OPT"
116       [[ -n $Cflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
117       Cflag="-$OPT"
118       nodesetId="$OPTARG"
119       [[ -n $aflag || -n $Wflag || -n $wflag || -n $nflag || -n $Nflag ]] &&  \
120         syntaxError "invalidCombination"  \
121           $usageMsg $Cflag $aflag $Wflag $wflag $nflag $Nflag
122       ;;
123
124    f) [[ -n $fflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
125       fflag="-$OPT"
126       ;;
127
128    n) [[ -n $nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
129       nflag="-$OPT"
130       nodenums="$OPTARG"
131       [[ -n $Cflag || -n $Wflag || -n $aflag || -n $Nflag ]] &&  \
132         syntaxError "invalidCombination"  \
133           $usageMsg $nflag $Cflag $Wflag $aflag $Nflag
134       ;;
135
136    N) [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
137       Nflag="-$OPT"
138       nodenames="$OPTARG"
139       [[ -n $Cflag || -n $Wflag || -n $aflag || -n $nflag || -n $wflag ]] &&  \
140         syntaxError "invalidCombination"  \
141           $usageMsg $Nflag $Cflag $Wflag $aflag $nflag $wflag
142       ;;
143
144    w) [[ -n $wflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
145       wflag="-$OPT"
146       nodenames="$OPTARG"
147       [[ -n $Cflag || -n $Wflag || -n $aflag || -n $Nflag ]] &&  \
148         syntaxError "invalidCombination"  \
149           $usageMsg $wflag $Cflag $Wflag $aflag $Nflag
150       ;;
151
152    W) [[ -n $Wflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
153       Wflag="-$OPT"
154       Wcoll="$OPTARG"
155       [[ -n $Cflag || -n $aflag || -n $wflag || -n $nflag || -n $Nflag ]] &&  \
156         syntaxError "invalidCombination"  \
157           $usageMsg $Wflag $Cflag $aflag $wflag $nflag $Nflag
158       ;;
159
160    :) syntaxError "missingValue" $usageMsg $OPTARG
161       ;;
162
163    +[aCfnNwW])
164       syntaxError "invalidOption" $usageMsg "$OPT"
165       ;;
166
167    *) syntaxError "invalidOption" $usageMsg $OPTARG
168       ;;
169
170  esac
171done  # end of while getopts :aC:fn:N:w:W: OPT do
172
173shift OPTIND-1
174[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
175
176# Rather than fail, convert the obsolete -C option to -a.
177[[ -n $Cflag ]] && aflag="-a"
178
179
180########################################################################
181# Set up trap exception handling and call the gpfsInit function.
182# It will ensure that the local copy of the mmsdrfs and the rest of the
183# GPFS system files are up-to-date.  There is no need to lock the sdr.
184########################################################################
185trap pretrap2 HUP INT QUIT KILL
186gpfsInitOutput=$(gpfsInit nolock)
187setGlobalVar $? $gpfsInitOutput
188
189
190#######################################################
191# Create a file containing all of the specified nodes.
192#######################################################
193if [[ -n $aflag ]]
194then
195  # Get a list of the nodes.
196  getNodeList $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile > $nodefile
197
198elif [[ -n $Nflag ]]
199then
200  # Convert the passed data into a file containing admin node names.
201  createVerifiedNodefile $nodenames $REL_HOSTNAME_Field no $nodefile
202  [[ $? -ne 0 ]] && cleanupAndExit
203
204elif [[ -n $Wflag ]]
205then
206  # Verify the input file is readable.
207  if [[ ! -f $Wcoll || ! -r $Wcoll ]]
208  then
209    printErrorMsg 43 $mmcmd $Wcoll
210    cleanupAndExit
211  fi
212
213  # Filter out comment lines and localhost entries.
214  $grep -v -e "localhost" -e "^#" "$Wcoll" > $tmpfile
215
216  # Convert any entries in the node file into admin node names.
217  if [[ -s $tmpfile ]]
218  then
219    createVerifiedNodefile $tmpfile $REL_HOSTNAME_Field no $nodefile
220    [[ $? -ne 0 ]] && cleanupAndExit
221  else
222    # No node names were specified.
223    printErrorMsg 328 $mmcmd $Wcoll
224    cleanupAndExit
225  fi
226
227else
228  # Either no option was specified, or we have some combination of -w and -n.
229
230  # Convert the node names list (if any) into a file.
231  $rm -f $tmpfile
232  if [[ -n $nodenames ]]
233  then
234    for i in $(print $nodenames | $tr "," " ")
235    do
236      print -- "$i" >> $tmpfile
237    done
238  fi
239
240  # Append the node number list (if any) to the node file.
241  if [[ -n $nodenums ]]
242  then
243    for i in $(print $nodenums | $tr "," " ")
244    do
245      print -- "$i" >> $tmpfile
246    done
247  fi
248
249  # Convert the entries in the node file into admin node names.
250  if [[ -s $tmpfile ]]
251  then
252    createVerifiedNodefile $tmpfile $REL_HOSTNAME_Field no $nodefile
253    [[ $? -ne 0 ]] && cleanupAndExit
254  fi
255
256fi  # end of if [[ -n $aflag ]]
257
258
259# Ensure we have the proper credentials.
260[[ $getCredCalled = no ]] && getCred
261
262
263##########################
264# Refresh the GPFS nodes.
265##########################
266if [[ ! -s $nodefile ]]
267then
268  # This is a request to refresh only the local node.
269  # Unless -f is specified, this is already done by gpfsInit above.
270  if [[ -n $fflag ]]
271  then
272    $mmremote cfg $fflag
273    rc=$?
274  else
275    : # There is nothing else to do.  If there is a need for
276      # additional processing that is not handled by gpfsInint,
277      # invoke the appropriate function.
278  fi
279else
280  # This is a request to refresh other nodes as well.
281  $mmcommon onall $nodefile $unreachedNodes cfg $fflag
282  rc=$?
283fi  # end of if [[ ! -s $nodefile ]]
284
285# If any nodes could not be reached, tell the user which ones.
286if [[ -s $unreachedNodes ]]
287then
288  # The following nodes could not be reached: . . .
289  printErrorMsg 270 $mmcmd
290  $cat $unreachedNodes 1>&2
291fi
292
293cleanupAndExit $rc
294
Note: See TracBrowser for help on using the repository browser.