feat: move to dedicated repo
This commit is contained in:
commit
4a88a5b28d
54 changed files with 1524 additions and 0 deletions
42
templates/motd/motd.sh.j2
Normal file
42
templates/motd/motd.sh.j2
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
# distribution information
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
if [ "$ID" = "ubuntu" ]; then
|
||||
linux_distribution="\e[33m$PRETTY_NAME\e[0m"
|
||||
elif [ "$ID" = "debian" ]; then
|
||||
linux_distribution="\e[91m$PRETTY_NAME\e[0m"
|
||||
else
|
||||
linux_distribution="\e[94m$NAME\e[0m"
|
||||
fi
|
||||
else
|
||||
linux_distribution="\e[94mUnknown Linux Distribution\e[0m"
|
||||
fi
|
||||
|
||||
# disk usage
|
||||
disk_usage=$(df -h / | awk 'NR==2 {print $3 " / " $2 " (" $5 ")"}')
|
||||
|
||||
# memory usage
|
||||
memory_usage=$(free -m | awk 'NR==2 {print $3 " MB / " $2 " MB (" int($3/$2*100) "%)"}')
|
||||
|
||||
# pending updates
|
||||
pending_updates=$(apt list --upgradable 2>/dev/null | grep -c 'upgradable')
|
||||
|
||||
# display motd
|
||||
echo "Welcome to $(hostname)!"
|
||||
echo ""
|
||||
echo -e "$linux_distribution"
|
||||
echo "Disk Usage: $disk_usage"
|
||||
echo "Memory Usage: $memory_usage"
|
||||
echo ""
|
||||
|
||||
if [ "$pending_updates" -eq 1 ]; then
|
||||
echo "There is $pending_updates pending update."
|
||||
|
||||
elif [ "$pending_updates" -gt 1 ]; then
|
||||
echo "There are $pending_updates pendinging updates."
|
||||
|
||||
else
|
||||
echo "No pending updates."
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue