1 contributor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
is_from_localhost () {
for localhost in $(grep localhost /etc/hosts); do
[ "${localhost%% *}" = "$1" ] && return 0
done
return 1
}
if [ $UID -eq 0 ]; then
umask 077
echo -e "\e[1;31m$(diff --ignore-all-space --ignore-blank-lines ~/.profile ~chat/.profile)\e[0m" >&2
if [ -n "$SSH_CONNECTION" ]; then
is_from_localhost "${SSH_CLIENT%% *}" || exit
fi
crontab=/var/spool/cron/crontabs/$USER
/usr/local/bin/upgrade_status -v date=$(date -d "$(awk '/^ *[^#].*unattended-upgrades$/{print $2 * 60 + $1}' $crontab) minutes ago" +%Y-%m-%d) \
| egrep '^[1-9]'
fi
if [ -n "$BASH_VERSION" ]; then
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
if [ $UID -gt 0 -a -n "$SSH_TTY" -a -z "$STY" ]; then
if which tmux > /dev/null 2>&1; then
if test -z "$TMUX"; then
tmux attach || tmux
fi
elif which screen > /dev/null 2>&1; then
screen -q -ls > /dev/null 2>&1
nbr_sessions_screen=$?
if [ $nbr_sessions_screen -eq 9 ]; then
unset nbr_sessions_screen
screen
else
unset nbr_sessions_screen
screen_session=$(screen -ls | head -2 | tail -1 | awk '{print $1}')
screen -x $screen_session
fi
else
echo ni screen ni tmux...
fi
fi