Salome HOME
PR: patch from Sergey Mozokhin (remote containers without SALOME APPLI)
[modules/kernel.git] / bin / runSalome
1 #!/bin/bash
2
3 save_config=$1
4
5 searchFreePort() {
6     echo -n "Searching for a free port for naming service: "
7     export NSPORT=2810
8     local limit=$NSPORT
9     let limit=limit+100
10     while [ 1 ]
11     do
12         aRes=`netstat -ltn | grep -E :${NSPORT}`
13         if [ -z "$aRes" ]; then
14             echo ${NSPORT} - Ok
15             local myhost=`hostname`
16             export OMNIORB_CONFIG=${HOME}/.omniORB_${myhost}_${NSPORT}.cfg
17             local initref="NameService=corbaname::"`hostname`":$NSPORT"
18             export NSPORT
19             if [[ `python -c "import CORBA; print CORBA.ORB_ID"` == "omniORB4" ]]; then
20                 echo "InitRef = $initref" > $OMNIORB_CONFIG
21             else
22                 echo "ORBInitRef $initref" > $OMNIORB_CONFIG
23             fi
24             if [[ "$save_config" == "--save-config" ]] ; then
25                 ln -sf $OMNIORB_CONFIG ${HOME}/.omniORB_current.cfg
26                 export OMNIORB_CONFIG=${HOME}/.omniORB_current.cfg
27             fi
28             break
29         fi
30         echo -n "${NSPORT} "
31         if [[ $NSPORT -eq $limit ]] ; then
32             echo
33             echo "Can't find a free port to launch omniNames"
34             echo "Try to kill the running servers and then launch SALOME again."
35             exit
36         fi
37         let NSPORT=NSPORT+1
38     done
39 }
40
41 searchFreePort
42
43 if [[ "$*" == "-nothing" ]]; then
44     echo "port:$NSPORT"
45 elif [ $# -ne 0 ] ; then
46     python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $* 
47 else
48     python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py
49 fi
50
51 # -----------------------------------------------------------------------------
52 # examples:
53 # ---------
54 #  $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome
55 #
56 #     - parameters for launching are taken from SalomeApp.xml;
57 #     - if the config file does not exist, it is created with default values.
58 #
59 #  
60 #  $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome --modules=GEOM,SMESH,VISU,SUPERV,MED --embedded=registry,study,moduleCatalog,cppContainer --standalone=pyContainer,supervContainer --xterm --killall
61 #
62 #     parameters from command line supersede those from SalomeApp.xml
63 #
64 # Some CORBA servers can be launched in the SALOME_Session_Server's process
65 # (embedded = same process) or in a separate process (standalone):
66 # --> registry,study,moduleCatalog,cppContainer
67 # Other CORBA servers could only be launched in separate process (standalone):
68 # --> pyContainer,supervContainer
69 #
70 # $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome -h
71 #    help
72 # -----------------------------------------------------------------------------
73 #
74 # l'option -i permet de garder l'interpreteur python ouvert :
75 # par defaut, les differents serveurs ouvrent des fenĂȘtres xterm
76 # (cf. runSalome.py)
77 # le serveur Logger n'est pas obligatoire (commentĂ© dans runSalome.py)
78
79 # -----------------------------------------------------------------------------