D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
proc
/
thread-self
/
root
/
etc
/
profile.d
/
Filename :
prompt.sh
back
Copy
################################################################################### # A T T E N T I O N ! # # This file is under puppet control! Do NOT make changes manually! # ################################################################################### if [ "$PS1" ]; then if [ "${USER}" == wh ] || [ "${USER}" == la2 ] || [ "${USER}" == root ] || [ "${USER}" == netops ] || [ "${USER}" == dcops ] || [ "${USER}" == hsdcops ] || [[ "${USER}" =~ hc_.+\. ]] || [ "${USER}" == techsup ] then if [[ "${TERM}" == xterm* ]] || [ "${TERM}" == screen ] then echo -ne "\033]0;${USER}@${HOSTNAME%%.*}"; echo -ne "\007" fi #for logins via ipmi/idrac console or VNC tty=$(tty) if [[ ${tty} =~ 'tty' ]]; then export SSH_TTY=$tty export SSHD_USER=$USER fi if [ -z "${SSHD_USER}" ]; then SSHD_USER=$(cat /proc/$PPID/environ 2>/dev/null| tr '\0' '\n' | grep '^SSHD_USER' | cut -d"=" -f2) #set SSHD_USER for Namecheap if [ -n "${SSHD_USER}" ]; then export SSHD_USER #set SSHD_USER for Spaceship else SSHD_USER=$(ps -o user= -p $$) pid="$$" while [ "${SSHD_USER}" == 'root' ] do ppid=$(cat /proc/$pid/status | grep "PPid" | awk '{print $2}') pid=$ppid SSHD_USER=$(ps -o user= -p "${ppid}") export SSHD_USER done fi fi #set SSH_TTY for both - Namecheap and Spaceship pid="$$" while [ -z "${SSH_TTY}" ] do ppid=$(cat /proc/$pid/status | grep "PPid" | awk '{print $2}') pid=$ppid export SSH_TTY=$(tr '\0' '\n' < /proc/"${ppid}"/environ | grep '^SSH_TTY' | cut -d'=' -f2) done export PROMPT_COMMAND='history -a >(tee -a ~/.bash_history |logger -p local4.alert -t "$SSHD_USER:[$USER]:[$SSH_TTY]:[$PWD]")' elif [[ -d /dev/fd && -d /var/.cagefs ]] then unset HISTTIMEFORMAT export PROMPT_COMMAND='history -a >(tee -a ~/.bash_history |logger -p local5.alert -t "${USER}:${PWD}")' fi fi