2 #------------------------------------------------------------------------------
4 # \\ / F ield | foam-extend: Open Source CFD
6 # \\ / A nd | For copyright notice see file Copyright
8 #------------------------------------------------------------------------------
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
26 # foamInstallationTest
29 # Checks the machine system, the installation of foam-extend, and the user's
30 # personal configuration for running foam-extend.
32 #------------------------------------------------------------------------------
35 FOAM_VERSION
=foam-extend-3.1
36 SUPPLIED_VERSION_GCC
=4.3.3
51 if [ ! -n $USER_NAME ]; then
55 #==============================================================================
57 #==============================================================================
60 echo "-------------------------------------------------------------------------------"
77 echo $1 |
tr -d " " |
wc -m |
tr -d " "
83 NOCHAR
=`expr $NOCHAR - 1`
84 if [ $NOCHAR -eq -1 ]; then
92 echo $1 |
wc -m |
tr -d " "
98 ONELEN
=`stringLength $1`
99 LDIFF
=`expr $ONELEN - $2`
100 if [ $LDIFF -le 1 ]; then
101 while [ $LDIFF -lt 0 ] ; do
103 LDIFF
=`expr $LDIFF + 1`
107 LDIFF
=`expr $LDIFF + 4`
108 WORD
=`echo "$WORD" | cut -c${LDIFF}-`
115 EXP_ENV
=`eval "echo $1"`
116 EXP_PATH
=`eval "echo $2"`
120 if [ `length $EXP_ENV` -gt 0 ] ; then
123 if /usr
/bin
/test -e $EXP_ENV ; then
125 if [ "$2" != noPath
]; then
134 -o "$e" = "${EXP_ENV}/bin" \
135 -o "${EXP_ENV}/lib" = "$e" \
147 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
150 if [ -e "$EXP_ENV" ] ; then
152 if [ "$2" != noPath
]; then
161 -o "$e" = "${EXP_ENV}/bin" \
162 -o "${EXP_ENV}/lib" = "$e" \
174 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
178 echo "`fixlen "$1" 21` --------- env variable not set --------- $3"
182 if [ "$EXISTS" = no
] ||
[ "$ON_PATH" = no
]; then
185 if [ "$3" = yes ] && [ "$ERROR" = true
]; then
186 CRITICALERROR
=`expr $CRITICALERROR + 1`
187 echo "WARNING: CRITICAL ERROR"
201 if /usr
/bin
/test ! -d "$d/$2" -a -x "$d/$2" ; then
208 if [ ! -d "$d/$2" -a -x "$d/$2" ]; then
221 reportExecutable
() {
223 APP_PATH
=`findExec $PATH $1`
225 if [ ! -n $APP_PATH ];then
226 echo "`fixlen "$1" 9`" "*** not installed ***"
230 echo " CRITICAL ERROR"
231 CRITICALERROR
=`expr $CRITICALERROR + 1`
234 echo " CRITICAL ERROR"
235 CRITICALERROR
=`expr $CRITICALERROR + 1`
248 | \grep ' Version:' \
249 | sed -e 's/.*Version:/Version:/' \
253 VERSION
=`$1 -v 2>&1 \
254 | grep 'gcc version' \
256 if [ ! "$VERSION" = "$SUPPLIED_VERSION_GCC" ]; then
257 echo "WARNING: gcc version does not match gcc supplied" \
258 "with this release of foam-extend"
259 echo " Supplied version: $SUPPLIED_VERSION_GCC"
260 echo " User version : $VERSION"
261 echo " Minimum required: $MIN_VERSION_GCC"
266 VERSION
=`$APP_PATH --version | head -1`
269 VERSION
=`$APP_PATH --version | head -1 | cut -d" " -f4`
274 VERSION
=`$1 --version 2>&1 | grep gzip | cut -d" " -f2`
277 VERSION
=`$1 --version | head -1 | cut -d" " -f2`
282 if [ "$APP_PATH" = "$APP_SPEC" ] ||
[ ! "$2" ]; then
283 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10` `fixlen "$APP_PATH" 58`"
285 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10`"
286 echo "WARNING: Conflicting installations:"
287 echo " foam-extend settings : $APP_SPEC"
288 echo " current path : $APP_PATH"
291 echo " CRITICAL ERROR"
292 CRITICALERROR
=`expr $CRITICALERROR + 1`
295 echo " CRITICAL ERROR"
296 CRITICALERROR
=`expr $CRITICALERROR + 1`
311 PINGTEST
=`/usr/sbin/ping $1 2>&1`
312 if [ "`echo $PINGTEST | grep alive`" != "" ] ; then
314 elif [ "`echo $PINGTEST | grep 'unknown host'`" != "" ] ; then
315 RESULT
="No_entry_for_\"$1\"_in_/etc/hosts"
317 RESULT
="Networking_cannot_reach_$1"
321 PINGTEST
=`/bin/ping -w 3 -c 1 $1 2>&1`
322 if [ "`echo $PINGTEST | grep '1 received'`" != "" ] ; then
324 elif [ "`echo $PINGTEST | grep 'unknown host'`" != "" ] ; then
325 RESULT
="No_entry_for_\"$1\"_in_/etc/hosts"
327 RESULT
="Networking_cannot_reach_$1"
332 echo "`fixlen "Pinging_
$1" 25` `fixlen "$RESULT" 45` `fixlen "$2" 5`"
334 if [ "$2" = yes ] && [ "$RESULT" != Successful
]; then
335 CRITICALERROR
=`expr $CRITICALERROR + 1`
336 echo "WARNING: CRITICAL ERROR"
343 telnet -e A
$1 $2 <<EOF
351 if [ -x "/usr/bin/telnet" ] ||
[ -x "/bin/telnet" ] ; then
352 RESULT
=`telnetPortTest $1 $2 2>&1 | egrep "onnect.* [t|r]"`
353 if [ "`echo $RESULT | grep 'Connected to'`" ] ; then
355 elif [ "`echo $RESULT | grep 'Connection refused'`" ] ; then
356 RESULT
='Unsuccessful_connection_refused*'
361 RESULT
='No_telnet_installed:_cannot_check*'
367 checkTelnetPort
$HOST_NAME 222
368 echo "`fixlen "Test_rsh
:" 25` `fixlen "$RESULT" 45` "yes""
369 if [ "$RESULT" != Successful
]; then
370 SSHRSHOK
=`expr $SSHRSHOK + 1`
376 checkTelnetPort
$HOST_NAME 22
377 echo "`fixlen "Test_ssh
:" 25` `fixlen "$RESULT" 45` "yes""
378 if [ "$RESULT" != Successful
]; then
379 SSHRSHOK
=`expr $SSHRSHOK + 1`
384 checkFoamEnvironment
() {
385 [ -d "$WM_PROJECT_INST_DIR" ] && [ -d "$WM_THIRD_PARTY_DIR" ] ||
{
387 echo "FATAL ERROR: foam-extend environment not configured."
389 echo " Please refer to the installation section of the file:"
390 echo " <foam installation dir>/${FOAM_VERSION}/ReleaseNotes-${FOAM_VERSION}"
391 echo " to source the foam-extend environment."
401 # USER_CONFIG_TYPE="cshrc"
402 echo "`fixlen "Shell
:" $WIDTH` ${SHELL##*/}"
405 # USER_CONFIG_TYPE="bashrc"
406 echo "`fixlen "Shell
:" $WIDTH` ${SHELL##*/}"
409 # USER_CONFIG_TYPE=""
410 echo "`fixlen "Shell
:" $WIDTH` ${SHELL##*/}"
411 echo "FATAL ERROR: Cannot identify the shell you are running."
412 echo " ${FOAM_VERSION} is compatible with "
413 echo " csh, tcsh, ksh and bash."
415 FATALERROR
=`expr $FATALERROR + 1`;;
421 if [ ! "$HOST_NAME" ]; then
422 echo "`fixlen "Host
:" $WIDTH` ${HOST_NAME}"
423 echo "FATAL ERROR: Cannot stat hostname."
424 echo " Contact your system administrator, "
425 echo " ${FOAM_VERSION} needs a valid "
426 echo " hostname to function."
428 FATALERROR
=`expr $FATALERROR + 1`
430 echo "`fixlen "Host
:" $WIDTH` ${HOST_NAME}"
437 Linux | LinuxAMD64 | SunOS
)
438 echo "`fixlen "OS
:" $WIDTH` ${OS} version $(uname -r)"
441 echo "FATAL ERROR: Incompatible operating system \"$OS\"."
442 echo " ${FOAM_VERSION} is currently "
443 echo " available for Linux and SunOS only."
445 FATALERROR
=`expr $FATALERROR + 1`
451 #==============================================================================
453 #==============================================================================
457 #------------------------------------------------------------------------------
458 heading
"Checking basic setup..."
466 #------------------------------------------------------------------------------
467 heading
"Checking main foam-extend env variables..."
468 COL1
=`fixlen "Environment_variable" 21`
469 COL2
=`fixlen "Set_to_file_or_directory" 40`
474 echo "$COL1 $COL2 $COL3 $COL5"
476 reportEnv
'$WM_PROJECT_INST_DIR' 'noPath' "yes"
477 reportEnv
'$WM_PROJECT_USER_DIR' 'noPath' "no"
478 reportEnv
'$WM_THIRD_PARTY_DIR' 'noPath' "yes"
481 #------------------------------------------------------------------------------
482 heading
"Checking the foam-extend env variables set on the PATH..."
484 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
486 reportEnv
'$WM_PROJECT_DIR' '$PATH' "yes"
488 reportEnv
'$FOAM_APPBIN' '$PATH' "yes"
489 reportEnv
'$FOAM_SITE_APPBIN' '$PATH' "no"
490 reportEnv
'$FOAM_USER_APPBIN' '$PATH' "no"
491 reportEnv
'$WM_DIR' '$PATH' "yes"
494 #------------------------------------------------------------------------------
495 heading
"Checking the foam-extend env variables set on the LD_LIBRARY_PATH..."
497 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
499 reportEnv
'$FOAM_LIBBIN' '$LD_LIBRARY_PATH' "yes"
500 reportEnv
'$FOAM_SITE_LIBBIN' '$LD_LIBRARY_PATH' "no"
501 reportEnv
'$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' "no"
502 reportEnv
'$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' "yes"
505 #------------------------------------------------------------------------------
506 heading
"Third party software"
507 COL1
=`fixlen "Software" 9`
508 COL2
=`fixlen "Version" 10`
509 COL3
=`fixlen "Location" 10`
511 echo "$COL1 $COL2 $COL3"
513 reportExecutable gcc
"${WM_COMPILER_DIR}/bin/gcc"
514 reportExecutable
gzip
515 if [ "$OS" = Linux
] ; then
518 reportExecutable gtar
520 reportExecutable icoFoam
"${FOAM_APPBIN}/icoFoam"
524 #------------------------------------------------------------------------------
528 if [ $FATALERROR -gt 0 ] ; then
529 echo "The system test has evoked $FATALERROR fatal error(s)."
531 echo "Base configuration ok."
534 if [ $CRITICALERROR -gt 0 ]; then
535 echo "The foam installation contains $CRITICALERROR critical error(s)."
537 echo "Critical systems ok."
540 if [ $CRITICALERROR -gt 0 ] ||
[ $FATALERROR -gt 0 ]; then
541 echo "Review the output for warning messages and consult "
542 echo "the installation guide for trouble shooting."
552 #------------------------------------------------------------------------------