2020-01-22 09:17:13 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-03-12 10:39:22 +01:00
|
|
|
# if we are root, exit after 5 Minutes
|
2020-03-12 18:26:04 +01:00
|
|
|
case $(tty) in
|
|
|
|
/dev/tty[0-9]*)
|
2020-03-12 21:34:23 +01:00
|
|
|
case $(id -u) in
|
2020-03-12 20:48:27 +01:00
|
|
|
0)
|
2020-03-12 20:59:57 +01:00
|
|
|
TMOUT=${MYSHELLCONFIG_ROOT_TMOUT:-500}
|
2020-03-12 20:48:27 +01:00
|
|
|
;;
|
|
|
|
*)
|
2020-03-12 21:38:39 +01:00
|
|
|
TMOUT=${MYSHELLCONFIG_USER_TMOUT:-1000}
|
2020-03-12 20:48:27 +01:00
|
|
|
;;
|
|
|
|
esac
|
2020-09-21 21:24:34 +02:00
|
|
|
loginfo "Run in TTY -> set autologout \$TMOUT=$TMOUT" >&2
|
2020-03-12 18:26:04 +01:00
|
|
|
;;
|
|
|
|
*)
|
2020-09-21 21:24:34 +02:00
|
|
|
loginfo "Run in graphical terminal - set no autologout" >&2
|
2020-08-05 07:55:39 +02:00
|
|
|
unset TMOUT
|
2020-03-12 18:26:04 +01:00
|
|
|
;;
|
|
|
|
esac
|
2020-03-12 10:39:22 +01:00
|
|
|
|
2020-01-22 09:17:13 +01:00
|
|
|
# Load default values, functions, aliases for myshellconfig
|
|
|
|
if ! $SSHS; then
|
|
|
|
if [ -e ${MYSHELLCONFIG_BASE}/functions.sh ]; then
|
|
|
|
. ${MYSHELLCONFIG_BASE}/functions.sh
|
|
|
|
else
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######################################################################################
|
|
|
|
# ls is not in color on all systems
|
|
|
|
export LS_OPTIONS='--color=auto'
|
|
|
|
eval "`dircolors`"
|
|
|
|
|
|
|
|
#######################################################################################
|
|
|
|
# User specific aliases and function
|
|
|
|
|
|
|
|
|
|
|
|
if [ -d "${MYSHELLCONFIG_BASE}/bin" ] ; then
|
|
|
|
pathmunge "${MYSHELLCONFIG_BASE}/bin"
|
|
|
|
export PATH
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "${MYSHELLCONFIG_BASE}/git-credential-pass" ] ; then
|
|
|
|
pathmunge "${MYSHELLCONFIG_BASE}/git-credential-pass"
|
|
|
|
export PATH
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "${MYSHELLCONFIG_BASE}/aliases" ]; then
|
|
|
|
. "${MYSHELLCONFIG_BASE}/aliases"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "${MYSHELLCONFIG_BASE}/PS1" ]; then
|
|
|
|
. "${MYSHELLCONFIG_BASE}/PS1"
|
|
|
|
fi
|
|
|
|
|
2020-09-21 17:49:39 +02:00
|
|
|
# Fehler anfang
|
|
|
|
#set -x
|
2020-01-22 09:17:13 +01:00
|
|
|
if [ -e "${MYSHELLCONFIG_BASH_COMPLETION}" ]; then
|
|
|
|
for i in $( ls "${MYSHELLCONFIG_BASH_COMPLETION}" ); do
|
|
|
|
. "${MYSHELLCONFIG_BASH_COMPLETION}/${i}"
|
|
|
|
done
|
2020-04-06 14:40:18 +02:00
|
|
|
unset i
|
2020-01-22 09:17:13 +01:00
|
|
|
fi
|
|
|
|
|
2020-09-21 17:49:39 +02:00
|
|
|
#set +x
|
|
|
|
# Fehler ende
|
|
|
|
|
2020-01-22 11:00:53 +01:00
|
|
|
if [ -f "${MYSHELLCONFIG_BASE}/myshell_load_fortmpconfig" ]; then
|
2020-01-22 10:47:19 +01:00
|
|
|
. "${MYSHELLCONFIG_BASE}/myshell_load_fortmpconfig"
|
|
|
|
fi
|
|
|
|
|
2020-01-22 09:17:13 +01:00
|
|
|
|
|
|
|
#########################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
# Go HOME
|
|
|
|
#cd ${HOME}
|
|
|
|
|
|
|
|
if test ! $TMUX && test $SSH_TTY && test $TERM != screen && test $(systemctl status tmux@${USER}.service 1>/dev/null 2>&1; echo $? ) -eq 0; then
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
"User: $USER - $UID"
|
|
|
|
|
|
|
|
Starting or resuming screen session
|
|
|
|
Press CTRL+C to cancel screen startup
|
|
|
|
|
|
|
|
EOF
|
|
|
|
sleep 1
|
|
|
|
#screen -UxR
|
|
|
|
tmux attach-session
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset -f pathmunge
|
|
|
|
|
|
|
|
else
|
|
|
|
# run with temporary config
|
|
|
|
|
|
|
|
case $TERM in
|
|
|
|
*screen*)
|
2020-09-21 21:24:34 +02:00
|
|
|
loginfo BASHRC: $BASHRC -> source it
|
2020-01-22 09:17:13 +01:00
|
|
|
#[ -e $BASHRC ] && . "$BASHRC"
|
|
|
|
if [ ! -z ${BASHRC+x} ]; then
|
|
|
|
if [ -e $BASHRC ] ; then
|
|
|
|
exec bash --rcfile "$BASHRC" -i /dev/null
|
|
|
|
else
|
|
|
|
exec bash -i
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
exec bash -i
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
fi
|
2020-01-22 10:10:10 +01:00
|
|
|
|
2020-02-12 12:21:26 +01:00
|
|
|
# Disable Ctrl+s to freeze terminal
|
|
|
|
# Source https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps
|
|
|
|
stty -ixon
|
2020-02-17 20:02:59 +01:00
|
|
|
export HISTCONTROL=erasedups:ignorespace:ignoredups
|
2020-02-17 20:16:34 +01:00
|
|
|
export HISTIGNORE="ls:l:cd:exit:pwd:date:mencfs:"
|
2020-02-13 06:39:02 +01:00
|
|
|
export HISTTIMEFORMAT='%F %T '
|
2020-02-13 06:40:21 +01:00
|
|
|
export HISTSIZE=999999
|
2020-01-22 10:10:10 +01:00
|
|
|
|
2020-09-21 21:24:34 +02:00
|
|
|
loginfo "bashrc_add sourced" 2>&1 |tee -a ${MYSHELLCONFIG_LOGFILE} >&2
|
2020-01-22 10:22:05 +01:00
|
|
|
#echo "bashrc_add sourced" >&2
|
2020-01-22 10:10:10 +01:00
|
|
|
|
2020-09-01 09:39:41 +02:00
|
|
|
# Export several functions for being usable in subshells
|
|
|
|
export -f token
|
|
|
|
export -f sudo
|
2020-09-01 09:41:14 +02:00
|
|
|
export -f reachable
|
2020-09-01 09:55:47 +02:00
|
|
|
export -f reachable-default
|
2020-09-21 21:24:34 +02:00
|
|
|
export -f logerror
|
|
|
|
export -f logwarn
|
|
|
|
export -f loginfo
|
|
|
|
export -f logdebug
|
|
|
|
export -f logtrace
|
2020-09-20 20:22:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
cat << EOF > ~/.ssh/agents/agent-default-$(hostname)
|
2020-09-21 18:04:30 +02:00
|
|
|
SSH_AUTH_SOCK=${SSH_AUTH_SOCK}; export SSH_AUTH_SOCK;
|
|
|
|
SSH_AGENT_PID=${SSH_AGENT_PID}; export SSH_AGENT_PID;
|
2020-09-21 21:24:34 +02:00
|
|
|
loginfo Agent pid ${SSH_AGENT_PID};
|
2020-09-20 20:22:48 +02:00
|
|
|
EOF
|
2020-09-21 16:46:13 +02:00
|
|
|
|
2020-09-21 17:49:39 +02:00
|
|
|
[ -z "${SSH_ADD_DEFAULT_OPTIONS+x}" ] && { SSH_ADD_DEFAULT_OPTIONS="-t 7200"; export SSH_ADD_DEFAULT_OPTIONS; }
|
|
|
|
[ -z "${SSH_IDENTITIES_DEFAULT_DIR+x}" ] && { SSH_IDENTITIES_DEFAULT_DIR="${HOME}/.ssh/identities"; export SSH_IDENTITIES_DEFAULT_DIR; }
|
|
|
|
[ -z "${SSH_AGENTS_DEFAULT_DIR+x}" ] && { SSH_AGENTS_DEFAULT_DIR="${HOME}/.ssh/agents"; export SSH_AGENTS_DEFAULT_DIR; }
|
|
|
|
[ -z "${SSH_AGENT_SOCKETS_DEFAULT_DIR+x}" ] && { SSH_AGENT_SOCKETS_DEFAULT_DIR="${HOME}/.ssh/agents"; export SSH_AGENT_SOCKETS_DEFAULT_DIR; }
|