# skip on mc session (subshell)
[ -n "${MC_TMPDIR}" ] && return 0

case $- in
	*i*)
		if [ -z "${VEIL_SHELL}" ]; then
			if [ -r /usr/share/veil/deb.subr ]; then
			    if [ -x /usr/bin/tmux ]; then
			        SESSIONNAME="${USER}_$( date +%Y%m%d_%H%M%S )"
                    if [ "${TERM}" != "linux" -a -z "$( find /usr/share/terminfo -type f -name \"${TERM}\" )" ]; then
                        TERM=xterm
                    fi
			        /usr/bin/tmux new -s ${SESSIONNAME}
			    else
				    [ -x /var/lib/ecp-veil/cli/app/shell.py ] && exec /var/lib/ecp-veil/cli/app/shell.py
				fi
				exit 0
			else
				echo "SpaceVM shell requires a veil-utils package"
			fi
			echo "VEIL_SHELL: Unable to execute /var/lib/ecp-veil/cli/app/shell.py, dropping to bash"
			exec bash --noprofile --norc
			exit 0
		else
			reset
			export PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '
			#export PATH=$PATH:/usr/share/openvswitch/scripts
			#reset
			# enable bash completion in interactive shells
			if [ -f /usr/share/bash-completion/bash_completion ]; then
				. /usr/share/bash-completion/bash_completion
			elif [ -f /etc/bash_completion ]; then
				. /etc/bash_completion
			fi
			SHELL=/bin/bash
			LRED='\001\033[1;31m\002'
			NORMAL='\001\033[0m\002'
			printf "${LRED}The shell system configuration is for vendor support only. You make changes by your only RISK !${NORMAL}\n\n"
		fi
		;;
	*)
		return 0
		;;
esac
