]> gitweb.morketsmerke.org Git - backup.git/commitdiff
Dodanie skryptu instalacji motd, na nowych serwerach
authorxf0r3m <jakubstasinski@protonmail.com>
Sat, 9 Mar 2024 08:39:17 +0000 (08:39 +0000)
committerxf0r3m <jakubstasinski@protonmail.com>
Sat, 9 Mar 2024 08:39:17 +0000 (08:39 +0000)
bashrc
install-motd.sh [new file with mode: 0755]
motd [new file with mode: 0755]

diff --git a/bashrc b/bashrc
index 246160df76db35d80097871f6a05b8ff662f6315..b75ec1a19a052bb23f79ade581b2bec3133e0c6e 100644 (file)
--- 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 (executable)
index 0000000..5a69103
--- /dev/null
@@ -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 (executable)
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 "====================================================================";