#!/bin/sh # distribution information if [ -f /etc/os-release ]; then . /etc/os-release linux_distribution="\033[36m$PRETTY_NAME\033[0m" else linux_distribution="\033[36mUnknown Linux Distribution\033[0m" fi # disk usage disk_usage=$(df -h / | awk 'NR==2 {print $3 " / " $2 " (" $5 ")"}') # memory usage (cgroup aware for LXC) if [ -f /sys/fs/cgroup/memory.current ]; then mem_used_kb=$(awk '{print int($1/1024)}' /sys/fs/cgroup/memory.current) mem_total_kb=$(awk '/MemTotal/ {print $2}' /proc/meminfo) mem_used_mb=$((mem_used_kb / 1024)) mem_total_mb=$((mem_total_kb / 1024)) mem_pct=$((mem_used_kb * 100 / mem_total_kb)) memory_usage="$mem_used_mb MB / $mem_total_mb MB ($mem_pct%)" else memory_usage=$(free -m | awk 'NR==2 {print $3 " MB / " $2 " MB (" int($3/$2*100) "%)"}') fi # display motd echo "Welcome to $(hostname)!" echo "" echo -e "$linux_distribution" echo "Disk Usage: $disk_usage" echo "Memory Usage: $memory_usage"