44 lines
1.2 KiB
Django/Jinja
44 lines
1.2 KiB
Django/Jinja
#!/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
|
|
if [ -f /etc/pve/version ] || [ -f /usr/bin/pveversion ]; then
|
|
linux_distribution="\e[38;5;208mProxmox VE $(cat /etc/pve/version 2>/dev/null || pveversion 2>/dev/null | cut -d'/' -f2)\e[0m"
|
|
else
|
|
linux_distribution="\e[91m$PRETTY_NAME\e[0m"
|
|
fi
|
|
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 pending updates."
|
|
else
|
|
echo "No pending updates."
|
|
fi
|