openfoam-selector.sh.in 1.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# -*- sh -*-
# Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
# Copyright (C) 2018 OpenCFD Ltd.
#
# File installed for Bourne-shell startups to select which OPENFOAM
# installation to use.  Not using "alternatives" because we want to be
# able to set per-user level defaults, not just system-wide defaults.

openfoam_selector_dir="@OPENFOAM_SELECTOR_DATADIR@"
openfoam_selector_homefile="$HOME/@OPENFOAM_SELECTOR_HOME_FILE@"
openfoam_selector_sysfile="@OPENFOAM_SELECTOR_SYSCONFDIR@/@OPENFOAM_SELECTOR_SYSCONFIG_FILE@"

# The selection name
unset openfoam_selection
if test -f "$openfoam_selector_homefile"
then
    openfoam_selection=$(cat $openfoam_selector_homefile)
elif test -f "$openfoam_selector_sysfile"
then
    openfoam_selection=$(cat $openfoam_selector_sysfile)
fi

# 1st: get selection name -> directory name correspondence
if test "$openfoam_selection" != "" -a -f "$openfoam_selector_dir/$openfoam_selection"
then
    openfoam_selection=$(cat "$openfoam_selector_dir/$openfoam_selection")

    # 2nd: test for and source OpenFOAM etc/bashrc
    if test "$openfoam_selection" != "" -a -f "$openfoam_selection/etc/bashrc"
    then
    . "$openfoam_selection/etc/bashrc"
    fi
fi
# -----------------------------------------------------------------------------