domain=`hostname -f | rev | cut -d. -f 1,2,3 | rev`
hostname=`hostname -f | sed s/$domain// | sed 's/\.$//'`

# load environment variables from /etc/environment
eval $(sed 's/^/export /' /etc/environment)

export MYSQL_PS1="\u@"$hostname" [\d]> "

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

HOST=`hostname -f | cut -f1 -d.`
[ -f ~/.prompt_colors ] && . ~/.prompt_colors
if [ "X$OVERRIDE_PS1" != "X" ]; then
        export PS1=$OVERRIDE_PS1
else
    case "$TERM" in
    xterm*)
        [[ ! -z "$QLOUD_COMPONENT" ]] && export PS1="\[\e[1;38;5;172m\]$QLOUD_APPLICATION.\[\e[38;5;34m\]$QLOUD_ENVIRONMENT.\[\e[38;5;32m\]$QLOUD_INSTANCE.\[\e[38;5;244m\]$HOST\[\e[0m\]:\w# "

        [[ ! -z "$DEPLOY_BOX_ID" ]] && export PS1="\[\e[1;38;5;172m\]$DEPLOY_STAGE_ID.\[\e[38;5;228m\]$DEPLOY_UNIT_ID.\[\e[38;5;34m\]$DEPLOY_BOX_ID.\[\e[38;5;32m\]$DEPLOY_POD_ID.\[\e[38;5;244m\]$DEPLOY_NODE_DC\[\e[0m\]:\w# "
        ;;
    *)
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
        ;;
    esac
fi


# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

alias ll='ls -l'

if [ -z $PGSSLROOTCERT ];then
    export PGSSLROOTCERT="/usr/local/share/ca-certificates/YandexInternalRootCA.crt"
fi
