# ***********************************************************************
#  This code is part of pyCMPL
#
#  Copyright (C) 2013 - 
#  Mike Steglich - Technical University of Applied Sciences
#  Wildau, Germany
#
#  pyCMPL is a project of the Technical University of
#  Applied Sciences Wildau and the Institute for Operations Research
#  and Business Management at the Martin Luther University
#  Halle-Wittenberg.
#  Please visit the project homepage <www.coliop.org>
#
#  pyCMPL is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  pyCMPL is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
#  License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# **********************************************************************

#!/bin/bash

oldPath=$PATH

CMPLHOME="`dirname \"$0\"`" 

if [[ $CMPLHOME = "." ]] ; then 
	CMPLHOME="$PWD/"
else 
	if [ ${0:0:1} = "/" ] ; then 
		CMPLHOME="$CMPLHOME/" 
	else
		CMPLHOME="$HOME/$CMPLHOME/" 
	fi
fi

export CMPLHOME


oldPath=$PATH 
PATH="$CMPLHOME":"$CMPLHOME"pyCmpl/scripts/Unix:"$CMPLHOME"Thirdparty/Python/bin:$PATH

export PATH

export PYTHONPATH="$CMPLHOME"pyCmpl/lib3:$PYTHONPATH
export PYTHONBIN="$CMPLHOME"Thirdparty/Python/bin/python3.9
	
	
oldPS1=PS1 

case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

if [ "$color_prompt" = yes ]; then
	PS1="\[\033[01;32m\]cmpl\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$" 
else
	PS1="cmpl:\w\$"
fi
export PS1

if [ -d ~/Documents ] ; then
	cd ~/Documents
else
	cd
fi 

echo ""
echo "###########################################################################"
echo "# Welcome to CmplShell                                                    #" 
echo "# Run cmpl (python3) to solve a Cmpl (pyCmpl) problem.                     #" 
echo "# To start or stop CmplServer please use cmplServer <-start|-stop> [port] #"
echo "# Type exit to leave the Cmpl environment                                 #"
echo "###########################################################################"
echo ""
exec $BASH --norc


PATH=$oldPath 
export PATH
PS1=$oldPS1 
export PS1


