2 #---------------------------------*- sh -*-------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
8 #------------------------------------------------------------------------------
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 # foamInstallationTest
29 # Checks the machine system, the installation of OpenFOAM, and the user's
30 # personal configuration for running OpenFOAM.
32 #------------------------------------------------------------------------------
50 if [ ! -n $USER_NAME ]; then
54 #==============================================================================
56 #==============================================================================
59 echo "-------------------------------------------------------------------------------"
76 echo $1 |
tr -d " " |
wc -m |
tr -d " "
82 NOCHAR
=`expr $NOCHAR - 1`
83 if [ $NOCHAR -eq -1 ]; then
91 echo $1 |
wc -m |
tr -d " "
97 ONELEN
=`stringLength $1`
98 LDIFF
=`expr $ONELEN - $2`
99 if [ $LDIFF -le 1 ]; then
100 while [ $LDIFF -lt 0 ] ; do
102 LDIFF
=`expr $LDIFF + 1`
106 LDIFF
=`expr $LDIFF + 4`
107 WORD
=`echo "$WORD" | cut -c${LDIFF}-`
114 EXP_ENV
=`eval "echo $1"`
115 EXP_PATH
=`eval "echo $2"`
119 if [ `length $EXP_ENV` -gt 0 ] ; then
122 if /usr
/bin
/test -e $EXP_ENV ; then
124 if [ "$2" != noPath
]; then
133 -o "$e" = "${EXP_ENV}/bin" \
134 -o "${EXP_ENV}/lib" = "$e" \
146 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
149 if [ -e "$EXP_ENV" ] ; then
151 if [ "$2" != noPath
]; then
160 -o "$e" = "${EXP_ENV}/bin" \
161 -o "${EXP_ENV}/lib" = "$e" \
173 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
177 echo "`fixlen "$1" 21` --------- env variable not set --------- $3"
181 if [ "$EXISTS" = no
] ||
[ "$ON_PATH" = no
]; then
184 if [ "$3" = yes ] && [ "$ERROR" = true
]; then
185 CRITICALERROR
=`expr $CRITICALERROR + 1`
186 echo "WARNING: CRITICAL ERROR"
200 if /usr
/bin
/test ! -d "$d/$2" -a -x "$d/$2" ; then
207 if [ ! -d "$d/$2" -a -x "$d/$2" ]; then
220 reportExecutable
() {
222 APP_PATH
=`findExec $PATH $1`
224 if [ ! -n $APP_PATH ];then
225 echo "`fixlen "$1" 9`" "*** not installed ***"
229 echo " CRITICAL ERROR"
230 CRITICALERROR
=`expr $CRITICALERROR + 1`
233 echo " CRITICAL ERROR"
234 CRITICALERROR
=`expr $CRITICALERROR + 1`
247 | \grep ' Version:' \
248 | sed -e 's/.*Version:/Version:/' \
252 VERSION
=`$1 -v 2>&1 \
253 | grep 'gcc version' \
255 verNum
=`echo "$VERSION" | sed s/[.]//g`
256 minVerNum
=`echo "$MIN_VERSION_GCC" | sed s/[.]//g`
258 if [ $verNum -lt $minVerNum ]; then
259 echo "CRITICAL ERROR: gcc version lower than required"
260 echo " Supplied version: $VERSION"
261 echo " Minimum required: $MIN_VERSION_GCC"
263 CRITICALERROR
=`expr $CRITICALERROR + 1`
267 VERSION
=`$APP_PATH --version | head -1`
270 VERSION
=`$APP_PATH --version | head -1 | cut -d" " -f4`
275 VERSION
=`$1 --version 2>&1 | grep gzip | cut -d" " -f2`
278 VERSION
=`$1 --version | head -1 | cut -d" " -f2`
283 if [ "$APP_PATH" = "$APP_SPEC" ] ||
[ ! "$2" ]; then
284 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10` `fixlen "$APP_PATH" 58`"
286 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10`"
287 echo "WARNING: Conflicting installations:"
288 echo " OpenFOAM settings : $APP_SPEC"
289 echo " current path : $APP_PATH"
292 echo " CRITICAL ERROR"
293 CRITICALERROR
=`expr $CRITICALERROR + 1`
296 echo " CRITICAL ERROR"
297 CRITICALERROR
=`expr $CRITICALERROR + 1`
312 PINGTEST
=`/usr/sbin/ping $1 2>&1`
313 if [ "`echo $PINGTEST | grep alive`" != "" ] ; then
315 elif [ "`echo $PINGTEST | grep 'unknown host'`" != "" ] ; then
316 RESULT
="No_entry_for_\"$1\"_in_/etc/hosts"
318 RESULT
="Networking_cannot_reach_$1"
322 PINGTEST
=`/bin/ping -w 3 -c 1 $1 2>&1`
323 if [ "`echo $PINGTEST | grep '1 received'`" != "" ] ; then
325 elif [ "`echo $PINGTEST | grep 'unknown host'`" != "" ] ; then
326 RESULT
="No_entry_for_\"$1\"_in_/etc/hosts"
328 RESULT
="Networking_cannot_reach_$1"
333 echo "`fixlen "Pinging_
$1" 25` `fixlen "$RESULT" 45` `fixlen "$2" 5`"
335 if [ "$2" = yes ] && [ "$RESULT" != Successful
]; then
336 CRITICALERROR
=`expr $CRITICALERROR + 1`
337 echo "WARNING: CRITICAL ERROR"
344 telnet -e A
$1 $2 <<EOF
352 if [ -x "/usr/bin/telnet" ] ||
[ -x "/bin/telnet" ] ; then
353 RESULT
=`telnetPortTest $1 $2 2>&1 | egrep "onnect.* [t|r]"`
354 if [ "`echo $RESULT | grep 'Connected to'`" ] ; then
356 elif [ "`echo $RESULT | grep 'Connection refused'`" ] ; then
357 RESULT
='Unsuccessful_connection_refused*'
362 RESULT
='No_telnet_installed:_cannot_check*'
368 checkTelnetPort
$HOST_NAME 222
369 echo "`fixlen "Test_rsh
:" 25` `fixlen "$RESULT" 45` "yes""
370 if [ "$RESULT" != Successful
]; then
371 SSHRSHOK
=`expr $SSHRSHOK + 1`
377 checkTelnetPort
$HOST_NAME 22
378 echo "`fixlen "Test_ssh
:" 25` `fixlen "$RESULT" 45` "yes""
379 if [ "$RESULT" != Successful
]; then
380 SSHRSHOK
=`expr $SSHRSHOK + 1`
385 checkOpenFOAMEnvironment
() {
386 [ -d "$WM_PROJECT_INST_DIR" ] && [ -d "$WM_THIRD_PARTY_DIR" ] ||
{
388 echo "FATAL ERROR: OpenFOAM environment not configured."
390 echo " Please refer to the installation section of the README file:"
391 echo " <OpenFOAM installation dir>/OpenFOAM-${FOAM_VERSION}/README"
392 echo " to source the OpenFOAM environment."
402 # USER_CONFIG_TYPE="cshrc"
403 echo "`fixlen "Shell
:" $WIDTH` ${SHELL##*/}"
406 # USER_CONFIG_TYPE="bashrc"
407 echo "`fixlen "Shell
:" $WIDTH` ${SHELL##*/}"
410 # USER_CONFIG_TYPE=""
411 echo "`fixlen "Shell
:" $WIDTH` ${SHELL##*/}"
412 echo "FATAL ERROR: Cannot identify the shell you are running."
413 echo " OpenFOAM ${FOAM_VERSION} is compatible with "
414 echo " csh, tcsh, ksh and bash."
416 FATALERROR
=`expr $FATALERROR + 1`;;
422 if [ ! "$HOST_NAME" ]; then
423 echo "`fixlen "Host
:" $WIDTH` ${HOST_NAME}"
424 echo "FATAL ERROR: Cannot stat hostname."
425 echo " Contact your system administrator, "
426 echo " OpenFOAM ${FOAM_VERSION} needs a valid "
427 echo " hostname to function."
429 FATALERROR
=`expr $FATALERROR + 1`
431 echo "`fixlen "Host
:" $WIDTH` ${HOST_NAME}"
438 Linux | LinuxAMD64 | SunOS
)
439 echo "`fixlen "OS
:" $WIDTH` ${OS} version $(uname -r)"
442 echo "FATAL ERROR: Incompatible operating system \"$OS\"."
443 echo " OpenFOAM ${FOAM_VERSION} is currently "
444 echo " available for Linux and SunOS only."
446 FATALERROR
=`expr $FATALERROR + 1`
452 #==============================================================================
454 #==============================================================================
458 #------------------------------------------------------------------------------
459 heading
"Checking basic setup..."
461 checkOpenFOAMEnvironment
467 #------------------------------------------------------------------------------
468 heading
"Checking main OpenFOAM env variables..."
469 COL1
=`fixlen "Environment_variable" 21`
470 COL2
=`fixlen "Set_to_file_or_directory" 40`
475 echo "$COL1 $COL2 $COL3 $COL5"
477 reportEnv
'$WM_PROJECT_INST_DIR' 'noPath' "yes"
478 reportEnv
'$WM_PROJECT_USER_DIR' 'noPath' "no"
479 reportEnv
'$WM_THIRD_PARTY_DIR' 'noPath' "yes"
482 #------------------------------------------------------------------------------
483 heading
"Checking the OpenFOAM env variables set on the PATH..."
485 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
487 reportEnv
'$WM_PROJECT_DIR' '$PATH' "yes"
489 reportEnv
'$FOAM_APPBIN' '$PATH' "yes"
490 reportEnv
'$FOAM_SITE_APPBIN' '$PATH' "no"
491 reportEnv
'$FOAM_USER_APPBIN' '$PATH' "no"
492 reportEnv
'$WM_DIR' '$PATH' "yes"
495 #------------------------------------------------------------------------------
496 heading
"Checking the OpenFOAM env variables set on the LD_LIBRARY_PATH..."
498 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
500 reportEnv
'$FOAM_LIBBIN' '$LD_LIBRARY_PATH' "yes"
501 reportEnv
'$FOAM_SITE_LIBBIN' '$LD_LIBRARY_PATH' "no"
502 reportEnv
'$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' "no"
503 reportEnv
'$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' "yes"
506 #------------------------------------------------------------------------------
507 heading
"Third party software"
508 COL1
=`fixlen "Software" 9`
509 COL2
=`fixlen "Version" 10`
510 COL3
=`fixlen "Location" 10`
512 echo "$COL1 $COL2 $COL3"
515 reportExecutable
gzip
516 if [ "$OS" = Linux
] ; then
519 reportExecutable gtar
521 reportExecutable icoFoam
"${FOAM_APPBIN}/icoFoam"
525 #------------------------------------------------------------------------------
529 if [ $FATALERROR -gt 0 ] ; then
530 echo "The system test has evoked $FATALERROR fatal error(s)."
532 echo "Base configuration ok."
535 if [ $CRITICALERROR -gt 0 ]; then
536 echo "*** The foam installation contains $CRITICALERROR critical error(s)"
538 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 #------------------------------------------------------------------------------