Created
August 11, 2024 22:50
-
-
Save dylanjamesdev/d0d116225ab51bcb49191775a90cf8a6 to your computer and use it in GitHub Desktop.
motd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PINK='\033[38;5;211m' | |
PURPLE='\033[38;5;135m' | |
INDIGO='\033[38;5;93m' | |
NC='\033[0m' # No Color | |
pad() { | |
local text="$1" | |
local padding=25 | |
local total_length=$((padding - ${#text})) | |
printf "%s" "$text" | |
printf "${NC}%0.s." $(seq 1 $total_length) | |
printf "${NC}:" | |
} | |
color_gradient_art() { | |
local color1="$1" | |
local color2="$2" | |
local color3="$3" | |
local art="$4" | |
local color_list=("$color1" "$color2" "$color3") | |
local color_count=${#color_list[@]} | |
while IFS= read -r line; do | |
local line_length=${#line} | |
local color_index=0 | |
for ((i=0; i<line_length; i++)); do | |
color_index=$((i % color_count)) | |
printf "${color_list[$color_index]}%s" "${line:$i:1}" | |
done | |
printf "${NC}\n" | |
done <<< "$art" | |
} | |
# ASCII Art | |
ascii_art=$(cat <<EOF | |
d8888 .d8888b. .d8888b. .d8888b. .d8888b. 888888888 8888888888 8888888888 | |
d88888 d88P Y88b d88P Y88b d88P Y88b d88P Y88b 888 d88P d88P | |
d88P888 Y88b. .d88P 888 888 .d88P 888 d88P d88P | |
d88P 888 "Y888b. 8888" Y88b. d888 8888" 8888888b. d88P d88P | |
d88P 888 "Y88b. "Y8b. "Y888P888 "Y8b. "Y88b 88888888 88888888 | |
d88P 888 "888 888 888 888 888 888 888 d88P d88P | |
d8888888888 Y88b d88P Y88b d88P Y88b d88P Y88b d88P Y88b d88P d88P d88P | |
d88P 888 "Y8888P" "Y8888P" "Y8888P" "Y8888P" "Y8888P" d88P d88P | |
EOF | |
) | |
color_gradient_art "$PINK" "$PURPLE" "$INDIGO" "$ascii_art" | |
echo "" | |
echo "" | |
# System Information | |
distro=$(lsb_release -ds || cat /etc/*release | grep ^NAME | head -n 1 | cut -d= -f2 | tr -d \") | |
kernel=$(uname -r) | |
echo -e "System Info:" | |
echo -e "${INDIGO}$(pad "Distribution")${NC} $distro" | |
echo -e "${INDIGO}$(pad "Kernel")${NC} $kernel" | |
echo "" | |
# Uptime, Load, Processes | |
uptime_info=$(uptime -p) | |
load=$(uptime | awk -F'load average:' '{ print $2 }' | xargs) | |
load_1=$(echo $load | cut -d, -f1) | |
load_5=$(echo $load | cut -d, -f2) | |
load_15=$(echo $load | cut -d, -f3) | |
processes=$(ps -e | wc -l) | |
echo -e "${INDIGO}$(pad "Uptime")${NC} $uptime_info" | |
echo -e "${INDIGO}$(pad "Load (1m)")${NC} $load_1" | |
echo -e "${INDIGO}$(pad "Load (5m)")${NC} $load_5" | |
echo -e "${INDIGO}$(pad "Load (15m)")${NC} $load_15" | |
echo -e "${INDIGO}$(pad "Processes")${NC} $processes" | |
echo "" | |
# CPU and Memory Usage | |
cpu_info=$(grep -m 1 'model name' /proc/cpuinfo | cut -d ':' -f 2 | xargs) | |
mem_total=$(free -h | grep Mem: | awk '{print $2}' | sed 's/Gi/G/') | |
mem_used=$(free -h | grep Mem: | awk '{print $3}' | sed 's/Gi/G/') | |
mem_free=$(free -h | grep Mem: | awk '{print $4}' | sed 's/Gi/G/') | |
echo -e "${INDIGO}$(pad "CPU")${NC} $cpu_info" | |
echo -e "${INDIGO}$(pad "Mem Used")${NC} $mem_used" | |
echo -e "${INDIGO}$(pad "Mem Available")${NC} $mem_free" | |
echo -e "${INDIGO}$(pad "Mem Total")${NC} $mem_total" | |
echo "" | |
# Disk Usage | |
disk_usage=$(df -h --total | grep total | awk '{print $3 " used / " $2 " total (" $5 " used)"}') | |
echo -e "${INDIGO}$(pad "Disk Usage")${NC} $disk_usage" | |
echo "" | |
# IPv4 and IPv6 Routes | |
ipv4_routes=$(ip -4 route | wc -l) | |
ipv6_routes=$(ip -6 route | wc -l) | |
echo -e "Routing:" | |
echo -e "${INDIGO}$(pad "IPv4 Routes")${NC} $ipv4_routes" | |
echo -e "${INDIGO}$(pad "IPv6 Routes")${NC} $ipv6_routes" | |
echo "" | |
# Network Interface Information | |
echo -e "${NC}Interfaces:" | |
interfaces=("ens18" "ens19" "ens20") | |
for iface in "${interfaces[@]}"; do | |
echo -e "${INDIGO}$iface:${NC}" | |
ip addr show "$iface" | grep -E "inet |inet6 " | awk '{print $2}' | while read -r ip; do | |
echo -e " IP.......................: $ip" | |
done | |
echo "" | |
done | |
# Tunnels | |
gre_tunnels=$(ip -d link show | grep -c gre) | |
echo -e "${INDIGO}$(pad "Tunnels")${NC} ${gre_tunnels}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment