source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmfsenv @ 177

Last change on this file since 177 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 5.1 KB
RevLine 
[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. 2000,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# @(#)10 1.28 src/avs/fs/mmfs/ts/admin/mmfsenv.sh, mmfs, avs_rgpfs24, rgpfs240610b 10/26/05 19:20:30
17#######################################################################
18#
19# mmfsenv is used to establish the environment and to load
20# the kernel extensions for GPFS and its support programs.
21#
22#  Usage:
23#    mmfsenv [-r | -u]  [other_options]
24#
25#  where
26#    -r             unload the current extensions first.
27#    -u             unload the kernel extensions and exit.
28#    other_options  all other options are passed through to
29#                   the load and unload routines.
30#
31#######################################################################
32#
33# This script assumes that the GPFS daemon is running in the context
34# of the mm command environment and performs a series of checks to
35# assure that this environment is correct and that all other needed
36# subsystems are present and operational.  If this behavior is not
37# desired, because GPFS is running in a single node or controlled
38# test environment, set the environment variable MMFSBYPASSCFG.
39#
40#######################################################################
41
42# Save the command line options before doing anything else.
43opts=$@
44
45#######################################################################
46# If this has not been done yet by the caller, determine the pathname
47# of the mm commands directory and include the global declarations.
48#######################################################################
49if [[ $commandPath != set ]]
50then
51  # Decide where to look for the commands.  The normal install directory
52  # is /usr/lpp/mmfs/bin.  This can be changed by setting the MMFSDIR
53  # environment variable to something other than /usr/lpp/mmfs.
54  # If MMFSDIR is not used, before assuming the default install directory,
55  # we will check if the mmfs binaries are in the same place where this
56  # script resides.  This is a development aid for running out of a build tree.
57  if [[ -n $MMFSDIR ]]
58  then
59    mmcmdDir="${MMFSDIR}/bin"
60  else
61    if [[ -z ${0%%/*} ]]
62    then
63      fullname="$0"
64    else
65      fullname="${PWD%/}/$0"
66    fi
67    progDir=${fullname%/*}
68
69    if [[ -f ${progDir}/mmfs ]]
70    then
71      mmcmdDir="$progDir"
72    else
73      mmcmdDir="/usr/lpp/mmfs/bin"
74    fi
75  fi
76
77  # Determine the values of mmcmdSubdir and mmcmdSuffix.
78  set -f ; set -- $(/bin/uname -a) ; set +f
79  osName=$1
80  osVersion=$4
81  set --
82  if [[ -f ${mmcmdDir}/mmfs || $osName != AIX || $osVersion < 5 ]]
83  then
84    mmcmdSubdir=""
85    mmcmdSuffix=""
86
87  else
88    # Must be running on top of AIX 5.
89    # Determine whether the current kernel is 64-bit.
90    kernelMode=$(${mmcmdDir}/mmkerninfo)
91    if [[ $kernelMode = 64 ]]
92    then
93      mmcmdSubdir="aix64"
94      mmcmdSuffix="64"
95    else
96      mmcmdSubdir="aix32"
97      mmcmdSuffix=""
98    fi
99  fi
100
101  # Include global declarations and service routines.
102  . ${mmcmdDir}/mmglobfuncs
103  . ${mmcmdDir}/mmsdrfsdef
104  . ${mmcmdDir}/mmfsfuncs
105
106  commandPath=set
107
108fi  # end of if [[ $commandPath != set ]]
109
110sourceFile="mmfsenv.sh"
111[[ -n $DEBUG || -n $DEBUGmmfsenv ]] && set -x
112$mmTRACE_ENTER "$*"
113
114# Set up trap exception handling.
115trap pretrap2 HUP INT QUIT KILL
116
117# Separate -r and -u from the rest of the options.
118myopt=""
119extopt=""
120for opt in $opts
121do
122  if [[ $opt = "-r" || $opt = "-u" ]]
123  then
124    myopt=$opt
125  else
126    extopt="$extopt $opt"
127  fi
128done
129
130# If Linux, make sure the extension is reloaded.
131[[ $osName = Linux && -z $myopt ]] && myopt="-r"
132
133# Add the GPFS command directory to the path.
134PATH="$PATH:$mmcmdDir:"
135
136# If requested, unload the kernel extensions.
137if [[ $myopt = "-r" || $myopt = "-u" ]]
138then
139  # If Linux, first try to unmount left over file systems.
140  [[ $osName = Linux ]] && $umount -a -t gpfs
141
142  # Unload the extensions.
143  unloadKernelExt $myopt
144  rc=$?
145
146  # If Linux, try to bring the daemon up even if the unloadKernExt failed.
147  if [[ $osName = Linux && $rc -ne 0 ]]
148  then
149    if [[ $myopt = "-u" ]]
150    then
151      rc=$MM_KExtFailure
152    else
153      rc=0
154    fi
155  fi
156
157  # If nothing else to do, or if an unrecoverable error, get out.
158  if [[ $myopt = "-u" || $rc -ne 0 ]]
159  then
160    $mmTRACE_EXIT "rc=$rc after unloadKernelExt "
161    return $rc
162  fi
163fi
164
165# Load the mmfs extension.
166loadKernelExt $extopt
167rc=$?
168[[ $osName = Linux && $rc -ne 0 ]] && rc=$MM_KExtFailure
169if [[ $rc -ne 0 ]]
170then
171  $mmTRACE_EXIT "rc=$rc loadKernelExt failure"
172  return $rc
173fi
174
175# If MMFSBYPASSCFG is set, do not do configuration initialization.
176# This is used when running without the mm commands and repository services.
177if [[ -n $MMFSBYPASSCFG ]]
178then
179  $mmTRACE_EXIT "rc=0 mmchecksubsys bypassed"
180  return 0
181fi
182
183# Verify and update the mmfs environment.
184. $mmchecksubsys
185rc=$?
186sourceFile="mmfsenv.sh"  # Restore value after in-line call to mmchecksubsys.
187
188$rm -f $GLOBAL_FILES $LOCAL_FILES
189$mmTRACE_EXIT "rc=$rc"
190return $rc
191
Note: See TracBrowser for help on using the repository browser.