Advertisement
Guest User

vtdStart1.sh

a guest
Aug 16th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.08 KB | None | 0 0
  1. #!/bin/bash
  2. # start script for VTD, last mod. July 04th, 2016
  3. #
  4. #(c) 2016 VIRES Simulationstechnologie GmbH
  5. #
  6. #
  7. # With VTD 2.0, processes are started by a component called "SimServer". This
  8. # will facilitate user configuration of a simulation in the future and will help
  9. # getting rid fo many shell scripts that have been used in the past
  10. #
  11.  
  12. # script may have been started with "-select" option in order to activate selection
  13. # of the current setup
  14. # script may have been started with "-autoConfig" to automatically read the autoCfg files in the
  15. # setup and project and apply them to the simulation
  16.  
  17. export VTD_SELECT_SETUP="false"
  18. export VTD_AUTO_CONFIG="false"
  19. export VTD_AUTO_START="false"
  20. export VTD_SET_PROJECT="false"
  21. export VTD_PROJECT_NAME="SampleProject"
  22. export VTD_SET_SETUP="false"
  23. export VTD_SETUP_NAME="Standard"
  24.  
  25. ## check command line
  26. for i in "$@"
  27. do
  28. case $i in
  29.   -select)
  30.       export VTD_SELECT_SETUP="true"
  31.   ;;
  32.  
  33.   -autoStart)
  34.       export VTD_AUTO_START="true"
  35.       export VTD_AUTO_CONFIG="true"
  36.   ;;
  37.   -autoConfig)
  38.       export VTD_AUTO_CONFIG="true"
  39.   ;;
  40.   -project=*)
  41.       export VTD_SET_PROJECT="true"
  42.       export VTD_PROJECT_NAME="${i#*=}"
  43.       export VTD_FORCE_PROJECT=$VTD_PROJECT_NAME
  44.   ;;
  45.   -setup=*)
  46.       export VTD_SET_SETUP="true"
  47.       export VTD_SETUP_NAME="${i#*=}"
  48.       export VTD_FORCE_SETUP=$VTD_SETUP_NAME
  49.   ;;
  50.   -h)
  51.           echo "usage: ./vtdStart.sh [-h] [-select] [-autoConfig] [-project=projectName]"
  52.           echo "    -h:          print this help"
  53.           echo "    -select:     select the active scenario"
  54.           echo "    -autoConfig: automatically apply the ParamServer configuration"
  55.           echo "    -autoStart:  automatically apply the ParamServer and execute start script 'tcAutoStart.scp'"
  56.           echo "    -project:    activate the given project"
  57.           echo "    -setup:      activate the given setup"
  58.           exit
  59.   ;;
  60.  
  61. esac
  62. done
  63.  
  64. #echo VTD_SELECT_SETUP is $VTD_SELECT_SETUP
  65. #echo VTD_AUTO_CONFIG is $VTD_AUTO_CONFIG
  66. #echo VTD_SET_PROJECT is $VTD_SET_PROJECT
  67. #echo VTD_PROJECT_NAME is $VTD_PROJECT_NAME
  68.  
  69. #verify setting of VTD_ROOT variable
  70. if [ -z $VTD_ROOT ]; then
  71.     export VTD_ROOT=$(pwd)
  72.    
  73. #check if user is already in bin directory
  74.     if [[ $PWD/ = */bin/ ]]; then
  75.         export VTD_ROOT=$VTD_ROOT/..
  76.     fi
  77. fi
  78.  
  79. # start from VTD_ROOT dir
  80. cd $VTD_ROOT
  81.  
  82. # remove any relative path components, refresh VTD_ROOT
  83. export VTD_ROOT=$(pwd)
  84.  
  85. echo "working in VTD_ROOT=$VTD_ROOT"
  86.  
  87. # first: stop the running simServer
  88.  
  89. #bin/vtdStop.sh
  90.  
  91. if [ "$VTD_SELECT_SETUP" = "true" ]; then
  92.     bin/selectSetup.sh
  93. fi
  94.  
  95. if [ "$VTD_SET_PROJECT" = "true" ]; then
  96.     echo linking current project to $VTD_PROJECT_NAME
  97.    
  98.     if [[ -e $VTD_ROOT/Data/Projects/Current ]]; then
  99.         rm -f $VTD_ROOT/Data/Projects/Current
  100.         ln -s $VTD_PROJECT_NAME $VTD_ROOT/Data/Projects/Current
  101.     else
  102.         echo "Link to current project not found. Exiting."
  103.         exit
  104.     fi
  105. fi
  106.  
  107. if [ "$VTD_SET_SETUP" = "true" ]; then
  108.     echo linking current setup to $VTD_SETUP_NAME
  109.    
  110.     if [[ -e $VTD_ROOT/Data/Setups/Current ]]; then
  111.         rm -f $VTD_ROOT/Data/Setups/Current
  112.         ln -s $VTD_SETUP_NAME $VTD_ROOT/Data/Setups/Current
  113.     else
  114.         echo "Link to current setup not found. Exiting."
  115.         exit
  116.     fi
  117. fi
  118.  
  119. # Ubuntu needs some extra seetings
  120. export HOSTNAME=$(hostname -s)
  121. export HOST=$HOSTNAME
  122. export XAUTHLOCALHOSTNAME=$HOSTNAME
  123. export GROUP=$GROUPS
  124. export HOSTTYPE=$HOSTTYPE
  125. export OSTYPE=$OSTYPE
  126.  
  127. # now let's start
  128.  
  129. echo starting the SimServer and GUI now on host $HOSTNAME...
  130.  
  131. CONFIG_FILE=$VTD_ROOT/Data/Setups/DualSim1/Config/SimServer/simServer.xml
  132. $VTD_ROOT/Runtime/Core/SimServer/simServer $CONFIG_FILE &
  133.  
  134. # shall the simulation be auto-configured (i.e. started)?
  135. if [ "$VTD_AUTO_CONFIG" = "false" ] ; then
  136.     exit 0
  137. fi
  138.  
  139. export VTD_SCP_GENERATOR_EXE=$VTD_ROOT/Runtime/Tools/ScpGenerator/scpGenerator
  140.  
  141. if [[ ! -x $VTD_SCP_GENERATOR_EXE ]]; then
  142.     echo "ScpGenerator executable could not be located!. Exiting."
  143.     exit 1
  144. fi
  145.  
  146. # auto-load setup parameters
  147. export VTD_PARAMSERVER_CONFIG_FILE=$VTD_ROOT/Data/Setups/DualSim1/Config/vtdParamServerAutoLoad.stp.xml
  148.  
  149. # those two are supposed to be temporary rather than environment variables
  150. # please set up environment variables in simServer.xml
  151. PORT_PARAMSERVER=54345
  152. PORT_SCP=48179
  153.  
  154. if [[ -e $VTD_PARAMSERVER_CONFIG_FILE ]]; then
  155.     echo "Reading setup parameters from $VTD_PARAMSERVER_CONFIG_FILE"
  156.     $VTD_SCP_GENERATOR_EXE -w -p $PORT_PARAMSERVER -P $VTD_PARAMSERVER_CONFIG_FILE
  157. fi
  158.  
  159. # auto-load project parameters
  160. local VTD_PARAMSERVER_CONFIG_FILE=$VTD_ROOT/Data/Projects/DualSim1/Config/vtdParamServerAutoLoad.prj.xml
  161.  
  162. if [[ -e $VTD_PARAMSERVER_CONFIG_FILE ]]; then
  163.     echo "Reading setup parameters from $VTD_PARAMSERVER_CONFIG_FILE"
  164.     $VTD_SCP_GENERATOR_EXE -w -p $PORT_PARAMSERVER -P $VTD_PARAMSERVER_CONFIG_FILE
  165. fi
  166.  
  167. echo "Applying configuration"
  168. $VTD_SCP_GENERATOR_EXE -w -p $PORT_SCP -i '<SimCtrl><Apply startByScript="'$VTD_AUTO_START'"/></SimCtrl>'
  169.  
  170.  
  171. # force 0 return code
  172. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement