]> SALOME platform Git repositories - modules/kernel.git/blob - bin/appliskel/runRemote.sh
Salome HOME
522b6ddd75e9f5888d078fa83175f49dc93589d5
[modules/kernel.git] / bin / appliskel / runRemote.sh
1 #!/bin/bash
2
3 # Copyright (C) 2005  OPEN CASCADE, CEA, EDF R&D, LEG
4 #           PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either 
8 # version 2.1 of the License.
9
10 # This library is distributed in the hope that it will be useful 
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 # Lesser General Public License for more details.
14
15 # You should have received a copy of the GNU Lesser General Public  
16 # License along with this library; if not, write to the Free Software 
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20
21 #
22 # --- run command in SALOME environment from remote call, ssh or rsh
23 #     - SALOME configuration is defined by :
24 #        - list of MODULE_ROOT_DIR
25 #        - prerequisite environment
26 #        - specific configuration for a particular SALOME application
27 #     - These elements of configuration are defined locally on each computer
28 #       in the directory APPLI:
29 #     - A SALOME application distributed on several computers needs APPLI
30 #       directories on the same path ($APPLI) relative to $HOME directory
31 #       of the user, on each computer.
32 #
33 # --- call example (from cli76cd to cli76ce):
34 # ssh cli76ce ${APPLI}/runRemote.sh cli76cd 2810 SALOME_Container myContainerName
35 #
36 # --- local arguments
37 #     $0 : ${APPLI}/runRemote.sh: from arg name, rebuild and export $APPLI variable
38 #     $1 : computer name for CORBA name service (where SALOME was launched)
39 #     $2 : port for CORBA name service
40 #     $3 : working directory
41 #     $4 and following : local command to execute, with args
42 #
43
44 # --- retrieve APPLI path, relative to $HOME, set ${APPLI}
45
46 APPLI_HOME=`dirname $0`
47 export APPLI=`${APPLI_HOME}/getAppliPath.py`
48
49 # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
50
51 . ${HOME}/${APPLI}/envd ${HOME}/${APPLI}
52
53 # --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME
54
55 OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_$1_$2.cfg
56 export OMNIORB_CONFIG
57 NSHOST=$1
58 export NSHOST
59 NSPORT=$2
60 export NSPORT
61 initref="NameService=corbaname::"$1":$2"
62 echo "ORBInitRef $initref" > $OMNIORB_CONFIG
63
64 #go to the requested working directory if any
65 if test "x$3" != x; then
66   if test "x$3" = "x\$TEMPDIR"; then
67     #create a temp working dir and change to it
68     WDIR=`mktemp -d` && {
69       cd $WDIR
70     }
71   else
72     if test -d $3; then
73       #the dir exists, go to it
74       cd $3
75     else
76       if test -a $3; then
77         # It's a file do nothing
78         echo $3 "is an existing file. Can't use it as a working directory"
79       else
80         #It does not exists, create it
81         mkdir -p $3 && {
82           cd $3
83         }
84       fi
85     fi
86   fi
87 fi
88
89 # --- execute the command in the SALOME environment
90
91 shift 3
92
93 # suppress --rcfile option because of problem on Mandriva2006 - B Secher mai 2007
94 #${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/sh --rcfile $HOME/$APPLI/.bashrc -c "$*"
95 ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/sh -c "$*"