Salome HOME
PR: merge from branch BR_auto_V310 tag mergefrom_OCC_development_for_3_2_0a2_10mar06
[modules/kernel.git] / bin / appliskel / runTests
1 #!/bin/bash
2
3 # --- retrieve APPLI path, relative to $HOME, set ${APPLI}
4
5 . `dirname $0`/setAppliPath.sh
6
7 # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
8
9 . ${HOME}/${APPLI}/envd ${HOME}/${APPLI}
10
11 # --- define port for CORBA naming service
12
13 searchFreePort() {
14     echo -n "Searching for a free port for naming service: "
15     export NSPORT=2810
16     local limit=$NSPORT
17     let limit=limit+100
18     while [ 1 ]
19     do
20         aRes=`netstat -ltn | grep -E :${NSPORT}`
21         if [ -z "$aRes" ]; then
22             echo ${NSPORT} - Ok
23             local myhost=`hostname`
24             OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_${NSPORT}.cfg
25             export OMNIORB_CONFIG
26             export NSPORT
27             NSHOST=${myhost}
28             export NSHOST
29             local initref="NameService=corbaname::"`hostname`":$NSPORT"
30             #echo "ORBInitRef $initref" > $OMNIORB_CONFIG
31             echo "InitRef = $initref" > $OMNIORB_CONFIG
32             LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_test.cfg
33             export LAST_RUNNING_CONFIG
34             rm ${LAST_RUNNING_CONFIG}
35             ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG}
36             break
37         fi
38         echo -n "${NSPORT} "
39         if [[ $NSPORT -eq $limit ]] ; then
40             echo
41             echo "Can't find a free port to launch omniNames"
42             echo "Try to kill the running servers and then launch SALOME again."
43             exit
44         fi
45         let NSPORT=NSPORT+1
46     done
47 }
48
49 # --- if mpi lam, start lam (seems safe to be done several times)
50 #     arret manuel avec lamhalt
51
52 if [ "$LAMBHOST" ]; then
53   lamboot
54 fi
55
56 # --- invoque shell with or without args
57
58 searchFreePort
59
60 if [ $# -ne 0 ] ; then
61     ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/sh --rcfile ${HOME}/${APPLI}/.bashrc -c "$*"
62 else
63
64     ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/sh --rcfile ${HOME}/${APPLI}/.bashrc
65 fi
66
67 rm ${OMNIORB_CONFIG}
68 rm ${LAST_RUNNING_CONFIG}