From 141057543db6f222d75d204a2a2bea76994cf326 Mon Sep 17 00:00:00 2001 From: xf0r3m Date: Sat, 9 Mar 2024 08:39:17 +0000 Subject: [PATCH] Dodanie skryptu instalacji motd, na nowych serwerach --- bashrc | 4 ++-- install-motd.sh | 11 +++++++++++ motd | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100755 install-motd.sh create mode 100755 motd diff --git a/bashrc b/bashrc index 246160d..b75ec1a 100644 --- a/bashrc +++ b/bashrc @@ -111,6 +111,6 @@ if ! shopt -oq posix; then . /etc/bash_completion fi fi -if ! $(ps -aux | grep "${USER}" | grep -q 'tmux\ .*'); then - tmux new-session -s t_xf0r3m 'bash /usr/local/bin/searx-motd && bash'; +if ! $(ps -ux | grep -q 'tmux\ .*'); then + tmux new-session -s t_${USER} 'bash /usr/local/bin/motd && bash'; fi diff --git a/install-motd.sh b/install-motd.sh new file mode 100755 index 0000000..5a69103 --- /dev/null +++ b/install-motd.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +sudo apt install -y tmux figlet lolcat; + +sudo git clone https://github.com/xero/figlet-fonts /usr/share/figlet-fonts; +sudo cp -v motd /usr/local/bin; +sudo chmod +x /usr/local/bin/motd; + +sudo sed -i "s/hostname/$(hostname)/" /usr/local/bin/motd; + +tail -3 bashrc >> ~/.bashrc; diff --git a/motd b/motd new file mode 100755 index 0000000..ad2eb7b --- /dev/null +++ b/motd @@ -0,0 +1,41 @@ +#!/bin/bash + +# Deps: figlet lolcat +# Deps GH: https://github.com/xero/figlet-fonts -> /usr/share/figlet-fonts; + +echo "hostname" | /usr/bin/figlet -c -f /usr/share/figlet-fonts/3d.flf | lolcat +echo; +echo "Today is: $(date)"; +echo; +echo "System summary: "; +cpuIdle=$(vmstat | tail -1 | awk '{printf $15}'); +cpuUsage=$((100 - $cpuIdle)); +echo -e " \tCPU: ${cpuUsage}%"; +echo -e " \tMEM: $(free -h | sed -n '2p' | awk '{printf $7}' | sed 's/i//') Free"; +echo -e " \tMount points:\tFree/Total\t(Usage%)"; +mountPointsList="/$ /home$"; +for mountPoint in $mountPointsList; do + if $(df -h 2>/dev/null | grep -q "${mountPoint}"); then + diskSize=$(df -h 2> /dev/null | grep "${mountPoint}" | awk '{printf $2}'); + diskFree=$(df -h 2> /dev/null | grep "${mountPoint}" | awk '{printf $4}'); + diskUsage_perc=$(df -h 2> /dev/null | grep "${mountPoint}" | sed 's/%//' | awk '{printf $5}'); + echo -e "\t$(echo $mountPoint | sed 's,\$,,'):\t\t${diskFree}/${diskSize}\t(${diskUsage_perc}%)"; + fi +done +echo -e " \tPROCESSES: $(ps -aux | wc -l | awk '{printf $1}')"; +if $(uptime | grep -q 'day'); then + utime=$(uptime | awk '{printf $3" "$4" "$5}' | sed -e 's/\,$//' -e 's,:,h ,'); + echo -e "\tUPTIME: ${utime}m"; +else + utime=$(uptime | awk '{printf $3}' | sed -e 's/,//' -e 's,:,h ,'); + if $(echo $utime | grep -q "h"); then + echo -e " \tUPTIME: ${utime}m"; + else + echo -e " \tUPTIME: 0h ${utime}m"; + fi +fi +echo -e " \t$(uptime | grep -o "load.*$" | tr [a-z] [A-Z])"; +echo; +echo -e "morketsmerke.org @ 2024 https://github.com/xf0r3m/immudex"; +echo; +echo "===================================================================="; -- 2.39.5