2 # Copyright (C) 2021 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 # $1 : IOR_OF_CURSTOM_NS of reference to Engines::EmbeddedNamingService servant
36 # $2 : WORKINGDIR (if $2 == WORKINDIR a working dir is given in $3. If not the working dir is $HOME)
37 # $3 : if $2 == WORKINGDIR, the path to the workingdir
38 # $4 (or $2 if no workingdir given) and following : local command to execute, with args
39 # --- retrieve APPLI path, relative to $HOME, set ${APPLI}
41 APPLI_HOME=$(dirname "$0")
42 export APPLI=$("${APPLI_HOME}/getAppliPath.py")
44 # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
45 # Sourcing files with parameters works with bash, not with dash. This is why
46 # we must use bash for this script.
48 . "${HOME}/${APPLI}/envd" "${HOME}/${APPLI}"
50 # --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME
51 export CUSTOM_NS_IOR=$1
53 #go to the requested working directory if any
54 if test "x$2" == "xWORKINGDIR"; then
55 if test "x$3" = "x\$TEMPDIR"; then
56 #create a temp working dir and change to it
57 WDIR=$(mktemp -d) && {
62 #the dir exists, go to it
66 # It's a file do nothing
67 echo "$3 is an existing file. Can't use it as a working directory"
69 #It does not exists, create it
81 # --- execute the command in the SALOME environment
83 "${KERNEL_ROOT_DIR}/bin/salome/envSalome.py" /bin/sh -c "$* $CUSTOM_NS_IOR"