Skip to content

Instantly share code, notes, and snippets.

@Cdaprod
Last active March 31, 2025 18:29
Show Gist options
  • Save Cdaprod/2c40dd97c3e66265dadae29d7c7f12cc to your computer and use it in GitHub Desktop.
Save Cdaprod/2c40dd97c3e66265dadae29d7c7f12cc to your computer and use it in GitHub Desktop.
Dynamic “Cdaprod” ascii + MOTD
# Sudo tee and EOF removed for scriptable runs.
#sudo tee /etc/update-motd.d/00-custom > /dev/null <<'EOF'
#!/usr/bin/env bash
# Colors
GREEN="\e[32m"
YELLOW="\e[33m"
CYAN="\e[36m"
MAGENTA="\e[35m"
RED="\e[31m"
RESET="\e[0m"
# Exit if in tmux session to avoid duplicate MOTD display
if [[ -n "$TMUX" ]]; then
exit 0
fi
# Get system info
HOSTNAME=$(hostname)
OS=$(lsb_release -d | cut -f2)
KERNEL=$(uname -r)
UPTIME=$(uptime -p)
LOAD=$(uptime | awk -F'load average:' '{ print $2 }')
MEMORY=$(free -m | awk '/Mem/ {printf "%.2f%%", $3/$2*100}')
DISK=$(df -h / | awk '/\// {print $5}')
BOOT_DISK=$(df -h /boot | awk '/\// {print $5}')
CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}')
# Check if Docker is running and list containers
if command -v docker &> /dev/null && [ "$(systemctl is-active docker)" == "active" ]; then
DOCKER_CONTAINERS=$(docker ps --format "{{.Names}}" | wc -l)
DOCKER_MSG="Docker: $DOCKER_CONTAINERS containers running"
else
DOCKER_MSG="Docker: Inactive or not installed"
fi
# Get current date and time
DATE=$(date +"%A, %B %d, %Y %H:%M:%S")
# Define ASCII logo for Cdaprod Pi
LOGO="
${CYAN} _____ __ __
/ ___/__/ /__ ____ _______ ___/ /
/ /__/ _ / _ \`/ _ \/ __/ _ \/ _ /
\___/\_,_/\_,_/ .__/_/ \___/\_,_/
/_/
${RESET}
"
# Print the logo
echo -e "$LOGO"
# Print system info inside a bordered layout
echo -e "${CYAN}+----------------------------------------+${RESET}"
echo -e "${GREEN}| Host: ${RESET}$HOSTNAME"
echo -e "${GREEN}| OS: ${RESET}$OS"
echo -e "${GREEN}| Kernel: ${RESET}$KERNEL"
echo -e "${GREEN}| Uptime: ${RESET}$UPTIME"
echo -e "${GREEN}| CPU Usage: ${RESET}$CPU"
echo -e "${GREEN}| Memory: ${RESET}$MEMORY"
echo -e "${GREEN}| Disk Usage: ${RESET}$DISK"
echo -e "${GREEN}| /boot Usage:${RESET} $BOOT_DISK"
echo -e "${GREEN}| Load Avg: ${RESET}$LOAD"
echo -e "${YELLOW}| Date: ${RESET}$DATE"
echo -e "${RED}| $DOCKER_MSG${RESET}"
echo -e "${CYAN}+----------------------------------------+${RESET}"
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment