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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
if test -n "$SHELLINABOX_URL" -a -z "$TMUX"; then
trap "exit 1" ZERR
if test ${SHELLINABOX_URL/https???seb.lautre.net} = $(sed -rn '/^ *location /N;/try_files .* @shellinabox/s|^ *location +([^ ]+).*$|\1/|p' /etc/nginx/sites-available/default); then
token=$(date +%s | sum)
$HOME/scripts/smsapi "shellinabox code: ${token// *1}"
read "user_token?token: "
if test "$user_token" != "${token// *1}"; then
exit 1
fi
unset token user_token
else
exit 1
fi
trap - ZERR
fi
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