ajout .profile
|
1 |
# ~/.profile: executed by the command interpreter for login shells. |
2 |
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login |
|
3 |
# exists. |
|
4 |
# see /usr/share/doc/bash/examples/startup-files for examples. |
|
5 |
# the files are located in the bash-doc package. |
|
6 | ||
7 |
# the default umask is set in /etc/profile; for setting the umask |
|
8 |
# for ssh logins, install and configure the libpam-umask package. |
|
9 | ||
protection pour accès shelli...
|
10 |
if test -n "$SHELLINABOX_URL" -a -z "$TMUX"; then |
11 |
trap "exit 1" ZERR |
|
12 |
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 |
|
13 |
token=$(date +%s | sum) |
|
14 |
$HOME/scripts/smsapi "shellinabox code: ${token// *1}" |
|
15 |
read "user_token?token: " |
|
16 |
if test "$user_token" != "${token// *1}"; then |
|
17 |
exit 1 |
|
18 |
fi |
|
modifie le mot de passe à ch...
|
19 |
sudo systemctl restart change-passwd.service |
protection pour accès shelli...
|
20 |
unset token user_token |
21 |
else |
|
22 |
exit 1 |
|
23 |
fi |
|
24 |
trap - ZERR |
|
25 |
fi |
|
26 | ||
ajout .profile
|
27 |
is_from_localhost () { |
28 |
for localhost in $(grep localhost /etc/hosts); do |
|
29 |
[ "${localhost%% *}" = "$1" ] && return 0 |
|
30 |
done |
|
31 |
return 1 |
|
32 |
} |
|
33 | ||
34 |
if [ $UID -eq 0 ]; then |
|
35 |
umask 077 |
|
36 |
echo -e "\e[1;31m$(diff --ignore-all-space --ignore-blank-lines ~/.profile ~chat/.profile)\e[0m" >&2 |
|
37 |
if [ -n "$SSH_CONNECTION" ]; then |
|
38 |
is_from_localhost "${SSH_CLIENT%% *}" || exit |
|
39 |
fi |
|
40 |
crontab=/var/spool/cron/crontabs/$USER |
|
41 |
/usr/local/bin/upgrade_status -v date=$(date -d "$(awk '/^ *[^#].*unattended-upgrades$/{print $2 * 60 + $1}' $crontab) minutes ago" +%Y-%m-%d) \ |
|
42 |
| egrep '^[1-9]' |
|
43 |
fi |
|
44 | ||
45 |
# if running bash |
|
46 |
if [ -n "$BASH_VERSION" ]; then |
|
47 |
# include .bashrc if it exists |
|
48 |
if [ -f "$HOME/.bashrc" ]; then |
|
49 |
. "$HOME/.bashrc" |
|
50 |
fi |
|
51 |
fi |
|
52 | ||
53 |
# set PATH so it includes user's private bin if it exists |
|
54 |
if [ -d "$HOME/bin" ] ; then |
|
55 |
PATH="$HOME/bin:$PATH" |
|
56 |
fi |
|
57 | ||
58 |
#if [ $UID -gt 0 -a -n "$SSH_TTY" -a -z "$STY" -a "$TERM" != "screen" ]; then |
|
59 |
if [ $UID -gt 0 -a -n "$SSH_TTY" -a -z "$STY" ]; then |
|
60 |
if which tmux > /dev/null 2>&1; then |
|
61 |
if test -z "$TMUX"; then |
|
62 |
tmux attach || tmux |
|
63 |
fi |
|
64 |
elif which screen > /dev/null 2>&1; then |
|
65 |
screen -q -ls > /dev/null 2>&1 |
|
66 |
nbr_sessions_screen=$? |
|
67 |
if [ $nbr_sessions_screen -eq 9 ]; then |
|
68 |
unset nbr_sessions_screen |
|
69 |
screen |
|
70 |
else |
|
71 |
unset nbr_sessions_screen |
|
72 |
screen_session=$(screen -ls | head -2 | tail -1 | awk '{print $1}') |
|
73 |
screen -x $screen_session |
|
74 |
fi |
|
75 |
else |
|
76 |
echo ni screen ni tmux... |
|
77 |
fi |
|
78 |
fi |