2 # Copyright (C) 2021-2022 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # --- run command in SALOME environment from remote call, ssh or rsh
22 # - SALOME configuration is defined by :
23 # - list of MODULE_ROOT_DIR
24 # - prerequisite environment
25 # - specific configuration for a particular SALOME application
26 # - These elements of configuration are defined locally on each computer
27 # in the directory APPLI:
28 # - A SALOME application distributed on several computers needs APPLI
29 # directories on the same path ($APPLI) relative to $HOME directory
30 # of the user, on each computer.
31 # --- call example (from cli76cd to cli76ce):
32 # ssh cli76ce ${APPLI}/runRemoteSSL.sh IOR_OF_CURSTOM_NS SALOME_Container myContainerName
34 # $0 : ${APPLI}/runRemote.sh: from arg name, rebuild and export $APPLI variable
35 # --noenvd : optional argument. If present, the envd file is NOT sourced.
36 # $1 : IOR_OF_CURSTOM_NS of reference to Engines::EmbeddedNamingService servant
37 # $2 : WORKINGDIR (if $2 == WORKINDIR a working dir is given in $3. If not the working dir is $HOME)
38 # $3 : if $2 == WORKINGDIR, the path to the workingdir
39 # $4 (or $2 if no workingdir given) and following : local command to execute, with args
40 # --- retrieve APPLI path, relative to $HOME, set ${APPLI}
42 APPLI_HOME=$(dirname "$0")
43 export APPLI=$("${APPLI_HOME}/getAppliPath.py")
45 # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
46 # Sourcing files with parameters works with bash, not with dash. This is why
47 # we must use bash for this script.
49 if [ "$1" == "--noenvd" ]
53 . "${HOME}/${APPLI}/envd" "${HOME}/${APPLI}"
56 #go to the requested working directory if any
57 if test "x$2" == "xWORKINGDIR"; then
58 if test "x$3" = "x\$TEMPDIR"; then
59 #create a temp working dir and change to it
60 WDIR=$(mktemp -d) && {
65 #the dir exists, go to it
69 # It's a file do nothing
70 echo "$3 is an existing file. Can't use it as a working directory"
72 #It does not exists, create it
84 # --- execute the command in the SALOME environment
86 "${KERNEL_ROOT_DIR}/bin/salome/envSalome.py" /bin/sh -c "$* "