# script to setup CAELinux environment

# avoid running in a loop
if [ -z $CAELinuxEnv ]; then 
export CAELinuxEnv=1

# autoconfigure ssh
/opt/caelinux/ssh-setup.sh 

# autoconfigure aster
if [ -z "`grep noeud /opt/aster113/etc/codeaster/asrun | grep $HOSTNAME`" ] ; then
 echo 'Hostname has changed, running autoconfig scripts for Code-Aster'
 /opt/caelinux/autoconfigAster.sh  
fi

# source openFoam variables
# . /opt/openfoam201/etc/bashrc
source /opt/caelinux/.bashrc-OpenFOAM

# caelinux tools
export PATH=$PATH:/opt/caelinux

# aster 11.3
if [ -e /opt/aster113 ]; then
  export PATH=$PATH:/opt/aster113/outils:/opt/aster110/bin
fi

# SALOME
if [ -e /opt/SALOME-MECA-2013.1 ]; then
  export PATH=$PATH:/opt/SALOME-MECA-2013.1/appli_V6_6_0/
fi

# buildDeb
if [ -e /opt/buildDeb ]; then
  export PATH=$PATH:/opt/buildDeb
fi

# CalculiX
if [ -e /opt/CalculiX ]; then
  export PATH=$PATH:/opt/CalculiX/ccx_2.5/bin/
fi

# CAM tOOLS
if [ -e /opt/cam-tools ]; then
  export PATH=$PATH:/opt/cam-tools/cadpy/:/opt/cam-tools/dxf2gcode/:/opt/cam-tools/gcam/bin/:/opt/cam-tools/grecode/:/opt/cam-tools/
fi

# Discretizer
if [ -e /opt/discretizer/ ]; then
  export PATH=$PATH:/opt/discretizer/
fi

# Elmer
if [ -e /opt/elmer ]; then
  export ELMER_HOME="/opt/elmer"
  export PATH=$ELMER_HOME/bin:$PATH
  export LD_LIBRARY_PATH=$ELMER_HOME/lib:$LD_LIBRARY_PATH
  export ELMERGUI_HOME=$ELMER_HOME/bin
  export ELMER_POST_HOME=$ELMER_HOME/bin
fi

# Helyx OS
if [ -e /opt/Engys/HelyxOS/v1.0.1/ ]; then
  export PATH=$PATH:/opt/Engys/HelyxOS/v1.0.1/
fi

# Impact
if [ -e /opt/Impact ]; then
  export PATH=$PATH:/opt/Impact
fi

# Itksnap 
if [ -e /opt/itksnap/bin/ ]; then 
  export PATH=$PATH:/opt/itksnap/bin
fi

# JavaFoil  and prop
if [ -e /opt/MH-AeroTools/ ]; then
  export PATH=$PATH:/opt/MH-AeroTools/JavaFoil/:/opt/MH-AeroTools/JavaProp
fi

# OpenSCAM
if [ -e /opt/openscam ]; then
  export PATH=$PATH:/opt/openscam
fi

# Pycam
if [ -e /opt/pycam-0.6-git ]; then
  export PATH=$PATH:/opt/pycam-0.6-git/scripts/
fi

# Saturne
if [ -e /opt/saturne-3.0/bin/ ]; then
  export PATH=$PATH:/opt/saturne-3.0/bin/
fi

# mbdyn
if [ -e /opt/mbdyn ]; then
  export PATH=$PATH:/opt/mbdyn
fi

# tetgen
if [ -e /opt/tetgen ]; then
  export PATH=$PATH:/opt/tetgen
fi

# voxelmesher
if [ -e /opt/VoxelMesher ]; then
  export PATH=$PATH:/opt/VoxelMesher
fi

# allow X connection locally
#xhost + localhost ${HOSTNAME} &>/dev/null


# end if
fi
