#!/bin/bash

#*****************************************************************
#                                                                *
#   Copyright (c) 2016 by FRIENDSHIP SYSTEMS AG                  *
#   Benzstr.2, D-14482 Potsdam                                   *
#   www.FRIENDSHIP-SYSTEMS.com                                   *
#                                                                *
#   This code and parts thereof are subject to                   *
#   license agreements. Unauthorized usage,                      *
#   modification, distribution, dissemination,                   *
#   and/or modification etc. is strictly prohibited.             *
#                                                                *
#   THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY            *
#   EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, WITHOUT          *
#   LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY        *
#   AND FITNESS FOR A PARTICULAR PURPOSE.                        *
#                                                                *
#*****************************************************************
#
# Rel:   FRIENDSHIP-SYSTEMS 4.2.1
# arch:  Linux.x86_64


##### If you want to use a FLOAT LICENSE
##### FLOAT ACCOUNT DATA required only durring first startup!! 
##### After first startup, email and password is saved in user cfg file.
#ARGS="-float" #enable, if you want to start in (offline) float mode
#export FS_FLOAT_USER="youremail@yourdomain.com"
#export FS_FLOAT_PASSWORD=yourpassword
# optinal to set the LICID or NotesString
#export FS_FLOAT_LICID=1000
#export FS_FLOAT_LICID=MYFLOATLICENSE
#####

##### LOCAL FLOAT LICENSE
# export FS_LIC_SRV=IPofYOURlicenseSERVER:PORT
# or in this format
# export FS_LIC_SRV=PORT@IPofYOURlicenseSERVER
##### valid examples
# export FS_LIC_SRV=192.168.25.102 # default port 8443 is used
# export FS_LIC_SRV=192.168.25.102:8443
# export FS_LIC_SRV=8443@192.168.25.102
#####

# You can setup the proxy access data via environment, 
# this will override the saved settings.
#export FS_PROXY_SERVER=proxy
#export FS_PROXY_PORT=8080
#export FS_PROXY_USER=user
#export FS_PROXY_PASSWORD=passwd

export FS_USER_DIR="$HOME/.friendship"
#unset FS_USER_DIR # unset the variable,
                   # if you want to start with temporary USERDIR
                   # check code below

abspath=$(cd ${0%/*} && echo $PWD/${0##*/})

# to get the path only - not the script name
FS_INSTALL_DIR=`dirname "$abspath"`


if [ -z $FSBASE ] ; then
  export FWORK=${FS_INSTALL_DIR}
fi  
if [ -z $FSBASE ] ; then
  export FSBASE=${FS_INSTALL_DIR}
fi
export FS_LIB_DIR=${FS_INSTALL_DIR}/lib/Linux.x86_64/:${FS_INSTALL_DIR}/tools/dakota/6.3.0/lib/
if [ -z $LD_LIBRARY_PATH ] ; then
  export LD_LIBRARY_PATH=$FS_LIB_DIR
else
  export LD_LIBRARY_PATH=$FS_LIB_DIR:$LD_LIBRARY_PATH
fi

# if you have "missing library" problems, uncomment the next line
# export LD_LIBRARY_PATH=${FS_INSTALL_DIR}/lib/Linux.x86_64/missing_libs/:$LD_LIBRARY_PATH

# please edit THIS line to define your system bus socket used by DBUS
export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket


if [ -z ${FS_CAESES_LICENSE} ]; then
  export HOST=`hostname -s`
  [ ! -d ~/.friendship/lic ] && mkdir -p ~/.friendship/lic/
#  export FS_CAESES_LICENSE=~/.friendship/lic/${HOST}_fslicense.dat
fi

if [ -z ${FS_USER_DIR} ]; then
  export FS_USER_DIR=/tmp/FFW_${USER}_$$
  ${FS_INSTALL_DIR}/bin/Linux.x86_64/CAESES_crt "$@"
  rm -rf ${FS_USER_DIR}
else
    ${FS_INSTALL_DIR}/bin/Linux.x86_64/CAESES_crt "$@"
fi


exit $?



# FAQ:
# Please check our Helpdesk for common issues
#
# https://helpdesk.caeses.com/support/solutions



