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