131 lines
4.3 KiB
Bash
131 lines
4.3 KiB
Bash
#!/bin/sh
|
|
#---------------------------------*- sh -*-------------------------------------
|
|
# ========= |
|
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
# \\ / O peration |
|
|
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
|
# \\/ M anipulation |
|
|
#------------------------------------------------------------------------------
|
|
# License
|
|
# This file is part of OpenFOAM.
|
|
#
|
|
# OpenFOAM is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
# for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Script
|
|
# foamConfigurePaths
|
|
#
|
|
# Description
|
|
# hardcode installation directory
|
|
#
|
|
#------------------------------------------------------------------------------
|
|
usage() {
|
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
cat<<USAGE
|
|
|
|
usage: ${0##*/}
|
|
--foamInstall dir specify installation directory (e.g. /opt)
|
|
--projectName name specify project name (e.g. openfoam170)
|
|
--archOption arch specify architecture option (only 32 or 64 applicable)
|
|
--paraviewInstall dir specify ParaView_DIR (e.g. /opt/paraviewopenfoam380)
|
|
|
|
* hardcode paths to installation
|
|
|
|
USAGE
|
|
exit 1
|
|
}
|
|
|
|
|
|
# Function to do replacement on file. Checks if any replacement has been done.
|
|
# inlineSed <file> <sedCommand> <description>
|
|
_inlineSed()
|
|
{
|
|
backup=`tempfile`
|
|
cp $1 $backup
|
|
sed -i -e "$2" $1
|
|
cmp --quiet $1 $backup && usage "Failed : $3"
|
|
return 0
|
|
}
|
|
|
|
|
|
[ -f etc/bashrc -a -f etc/settings.sh ] || usage "Please run from top-level directory of installation"
|
|
|
|
unset foamInstall projectName archOption paraviewInstall
|
|
|
|
# parse options
|
|
while [ "$#" -gt 0 ]
|
|
do
|
|
case "$1" in
|
|
-h | --help)
|
|
usage
|
|
;;
|
|
--foamInstall)
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
foamInstall="$2"
|
|
_inlineSed \
|
|
etc/bashrc \
|
|
'/^[^#]/s@foamInstall=.*@foamInstall='"$foamInstall@" \
|
|
"Replacing foamInstall setting by $foamInstall"
|
|
shift 2
|
|
;;
|
|
--projectName)
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
projectName="$2"
|
|
_inlineSed \
|
|
etc/bashrc \
|
|
'/^[^#]/s@WM_PROJECT_DIR=.*@WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/'"$projectName@" \
|
|
"Replacing WM_PROJECT_DIR setting by $projectName"
|
|
shift 2
|
|
;;
|
|
--archOption)
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
archOption="$2"
|
|
_inlineSed \
|
|
etc/bashrc \
|
|
'/^[^#]/s@: ${WM_ARCH_OPTION:=64}@WM_ARCH_OPTION='"$archOption@" \
|
|
"Replacing WM_ARCH_OPTION setting by $archOption"
|
|
shift 2
|
|
;;
|
|
--paraviewInstall)
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
paraviewInstall="$2"
|
|
_inlineSed \
|
|
etc/apps/paraview3/bashrc \
|
|
'/^[^#]/s@ParaView_DIR=.*@ParaView_DIR='"$paraviewInstall@" \
|
|
"Replacing ParaView_DIR setting by $paraviewInstall"
|
|
shift 2
|
|
;;
|
|
*)
|
|
usage "unknown option/argument: '$*'"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
[ -n "$foamInstall" -o -n "$projectName" -o -n "$archOption" -o -n "$paraviewInstall" ] || usage "Please specify at least one configure option"
|
|
|
|
#echo "Replacing WM_PROJECT setting by $projectName"
|
|
#sed -i -e 's@WM_PROJECT=.*@WM_PROJECT='"$projectName@" etc/bashrc
|
|
|
|
# Replace the WM_MPLIB always
|
|
_inlineSed \
|
|
etc/bashrc \
|
|
'/^[^#]/s@: ${WM_MPLIB:=.*}@WM_MPLIB=SYSTEMOPENMPI@' \
|
|
"Replacing WM_MPLIB setting by SYSTEMOPENMPI"
|
|
# Replace the compilerInstall always
|
|
_inlineSed \
|
|
etc/settings.sh \
|
|
'/^[^#]/s@: ${compilerInstall:=.*}@compilerInstall=system@' \
|
|
"Replacing compilerInstall setting by system"
|
|
|
|
#------------------------------------------------------------------------------
|