-
Notifications
You must be signed in to change notification settings - Fork 2
/
_bash_profile_raspbian
87 lines (75 loc) · 2.78 KB
/
_bash_profile_raspbian
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
79
80
81
82
83
84
85
86
87
# ~/.bash_profile
# Systatus BASH Shell Start-up for Raspbian
# r2019-02-20 fr2016-10-18
# by Valerio Capello - http://labs.geody.com/ - License: GPL v3.0
# Config
tshilon="\e[0;33m"; tshilof="\e[0m";
tsalerton="\e[0;31m"; tsalertof="\e[0m";
# Set Terminal Window Size
# tlins=40; tcols=160; echo -e "\e[8;$tlins;${tcols}t";
# Get Terminal Window Size
COLUMNS="$(tput cols)"; LINES="$(tput lines)";
# Prompt
export PS1="\[\e[1;32m\][\$(date +%Y-%m-%d\ %H:%M:%S\ %a)] \u@\h:\w\\\$\[\e[0m\] "
# History Date Format
export HISTTIMEFORMAT="%F %T "
# Aliases
alias l="ls -laF --group-directories-first --color=auto"
alias d="ls -aF --group-directories-first --color=auto"
# Message
echo; clear
date "+%a %d %b %Y %H:%M:%S %Z (UTC%:z)"
echo -n "Hello "; echo -ne "$tshilon"; echo -n "$(whoami)"; echo -ne "$tshilof";
if [[ "$SSH_CONNECTION" ]]; then
echo -n " ("; echo -ne "$tshilon"; echo -n "`echo $SSH_CLIENT | awk '{print $1}'`"; echo -ne "$tshilof)";
fi
echo -n ", ";
echo -n "welcome to "; echo -ne "$tshilon"; echo -n "$(hostname)";
echo -ne "$tshilof";
echo -n " ("; echo -ne "$tshilon"; echo -n "$(hostname -i)"; echo -ne "$tshilof)";
echo ".";
echo -n "Machine ID: "; echo -n "$(cat /etc/machine-id) ";
echo -n "Boot ID: "; echo "$(cat /proc/sys/kernel/random/boot_id) ";
echo -n "You are ";
if [[ -n "$SSH_CONNECTION" ]]; then
echo -n "connected remotely via SSH";
elif [[ "${DISPLAY%%:0*}" != "" ]]; then
echo -n "connected remotely "; echo -ne "$tsalerton"; echo -n "NOT";
echo -ne "$tsalertof"; echo " via SSH (which is Bad)";
else
echo -n "connected locally";
fi
echo ". Your Terminal Window Size is $COLUMNS x $LINES"
if [[ $EUID -eq 0 ]]; then
echo -ne "$tsalerton"; echo -n "You have ROOT superpowers!"; echo -e "$tsalertof";
fi
echo
# Machine
echo -n "CPU: "; echo -n "$(grep 'model name' /proc/cpuinfo | head -1). ";
echo -n "Cores: "; grep -c 'processor' /proc/cpuinfo
free -mh | xargs | awk '{print "Memory: Size: "$8" Used: "$9" Free: "$10" Avail: "$13}';
df / -Th | xargs | awk '{print "FS: "$9" Type: "$10" Size: "$11" Used: "$12" ("$14") Avail: "$13" ("(100-$14)"%)"}';
echo; echo -n "Uptime: "; uptime
echo
# Software version
uname -a
echo "Bash version: $BASH_VERSION"
# Webserver version
# echo -n "$(/usr/sbin/apache2 -v|head --lines=1) "; echo "$(/usr/sbin/apache2 -v|tail --lines=1)";
openssl version -v
# php -v|head --lines=1
# mysql -V
# echo
# echo -n "Installed Packages: "; dpkg --get-selections | wc -l;
# echo "Last installed packages:"; grep install /var/log/dpkg.log | tail --lines=5;
echo
# Users
echo "Last logged users:"; last -n 5 | sed '/^$/d'
echo; echo "Currently logged users:"; who
# echo; echo -n "Current user: "; id
echo
# Security
# Shellshock vulnerability check (reports to root only)
if [[ $EUID -eq 0 ]]; then
env x='() { :;}; echo Bash vulnerable to Shellshock' bash -c 'echo -n'
fi