#!/bin/sh # ############################# # # BUDYN.WTF # # # Weather MOTD # # ############################# # ---------------------------------------------------------------------- # Adapted from 15-mosto by Steeve L (Copyright (c) 2024-2025), MIT License. # Original project: https://freeshell.de/harpazo/motd/mostodon.php # 15-mosto credits visual inspiration to ar51an's Raspberry Pi MOTD, # Copyright (c) 2021 AA, MIT License: https://github.com/ar51an/raspberrypi-motd # # MIT License # # Copyright (c) 2024-2025 Steeve L # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # ---------------------------------------------------------------------- # Test this script alone or run the full MOTD with: sudo run-parts /etc/update-motd.d/ # Weather API settings. Keep the API key in a root-readable curl config file. # API documentation and usage examples: https://budyn.wtf/api-docs API_URL='https://budyn.wtf/api/v1/weather' API_CURL_CONFIG='/etc/budyn-weather.curl' WEATHER_CITY='Doncaster' WEATHER_COUNTRY='GB' WEATHER_SCALE='C' # CPU temperature unit: C or F. No value is shown if no supported sensor is readable. CPU_TEMP_SCALE='C' WEATHER_CONDITIONS=2 WEATHER_CACHE_SECONDS=600 # Optional sections. Set each value to "on" or "off". fail2ban=on show_Last_Login=on show_Docker=on show_SSH=on show_Ping=on show_IP=on FAIL2BAN_STATS_FILE='/var/www/budyn/admin/data/monitoring/f2b_stats.json' # Update these server-specific footer values when installing on another host. NEWS_RESET='[22.07.2026 18:15:00] Pierwszy reset dedyka ;-)' NEWS_OLD_UPTIME='133 days, 5 hrs, 37 mins' INFO_URL='https://budyn.wtf' # Terminal colors matching the original Tuxic theme. RESET='\033[0m' DIM='\033[38;5;241m' BAR_DIM='\033[38;5;238m' BULLET='\033[38;5;39m' ASTERISK_COLOR='\033[38;5;35m' WELCOME='\033[38;5;36m' USER_COLOR='\033[38;5;45m' HOST_COLOR='\033[38;5;172m' MODEL_COLOR='\033[38;5;236;48;5;248;1m' DATE_COLOR='\033[38;5;103m' WEATHER_COLOR='\033[38;5;103m' SYSTEM_COLOR='\033[38;5;103m' LABEL_COLOR='\033[38;5;186m' FOOTER_GREEN='\033[0;32m' BAR_GREEN='\033[38;5;40m' BAR_YELLOW='\033[38;5;11m' BAR_RED='\033[38;5;9m' BOOT_DATE_COLOR='\033[38;5;31m' UPTIME_COLOR='\033[38;5;36m' CPU_TEXT_COLOR='\033[38;5;6m' CPU_VALUE_COLOR='\033[38;5;150m' LOAD_TEXT_COLOR='\033[38;5;38m' LOAD_VALUE_COLOR='\033[38;5;150m' MEMORY_TEXT_COLOR='\033[38;5;73m' MEMORY_VALUE_COLOR='\033[38;5;144m' STORAGE_TEXT_COLOR='\033[38;5;74m' STORAGE_VALUE_COLOR='\033[38;5;144m' LAST_LOGIN_DATE_COLOR='\033[38;5;72m' LAST_LOGIN_IP_COLOR='\033[38;5;144m' CUSTOM_STAT_COLOR='\033[38;5;117m' IP_COLOR='\033[38;5;30m' PENGUIN_BLUE='\033[38;5;31m' PENGUIN_WHITE='\033[38;5;255m' PENGUIN_GOLD='\033[38;5;172m' PENGUIN_EYE='\033[38;5;144m' # Print plain text between a color and the reset sequence. paint() { printf '%b%s%b' "$1" "$2" "$RESET" } # Draw one welcome line and align the penguin by terminal display width. main_line() { text=$1 color=$2 art_line=$3 printf ' %b»%b ' "$BULLET" "$RESET" paint "$color" "$text" text_width=$(printf '%s\n' "$text" | LC_ALL=C.UTF-8 wc -L) padding=$((44 - 3 - text_width)) [ "$padding" -ge 2 ] || padding=2 printf '%*s' "$padding" '' penguin_line "$art_line" printf '\n' } # Color the welcome text by user and host, matching the original theme. welcome_line() { printf ' %b»%b ' "$BULLET" "$RESET" paint "$WELCOME" 'Welcome' paint "$USER_COLOR" " $login_user" paint "$WELCOME" ' to ' paint "$HOST_COLOR" "$server_name" paint "$WELCOME" '!' printf '\n' } # Draw the original penguin, including its gray eye and orange beak. penguin_line() { case "$1" in 1) printf '%b __%b' "$PENGUIN_BLUE" "$RESET" ;; 2) printf '%b <' "$PENGUIN_GOLD" printf '%b o ' "$PENGUIN_EYE" printf '%b)%b' "$PENGUIN_BLUE" "$RESET" ;; 3) printf '%b /' "$PENGUIN_WHITE" printf '%b' "$PENGUIN_BLUE" printf '%s' '\\\' printf '%b' "$RESET" ;; 4) printf '%b_' "$PENGUIN_BLUE" printf '%b' "$PENGUIN_WHITE" printf '%s' '\' printf '%b_V/%b' "$PENGUIN_BLUE" "$RESET" ;; esac } # Print a dotted label and arrow for a system-statistics row. stat_prefix() { label=$1 label_width=$(printf '%s\n' "$label" | LC_ALL=C.UTF-8 wc -L) dots=$((17 - label_width)) [ "$dots" -ge 1 ] || dots=1 printf ' ' paint "$LABEL_COLOR" "$label" i=0 while [ "$i" -lt "$dots" ]; do printf '%b·%b' "$DIM" "$RESET" i=$((i + 1)) done printf '%b›%b ' "$LABEL_COLOR" "$RESET" } # Print a system-statistics row using the matching category color. stat_line() { label=$1 value_color=$2 value=$3 stat_prefix "$label" paint "$value_color" "$value" printf '\n' } # Draw a 20-character bar with the original 70% and 90% color thresholds. progress_bar() { percent=$1 case "$percent" in ''|*[!0-9]*) percent=0 ;; esac [ "$percent" -gt 100 ] && percent=100 [ "$percent" -lt 0 ] && percent=0 filled=$((percent * 4 / 20)) bar_state=$BAR_GREEN printf '%b[' "$LABEL_COLOR" i=1 while [ "$i" -le 20 ]; do if [ "$i" -le "$filled" ]; then if [ "$i" -lt 14 ]; then bar_state=$BAR_GREEN elif [ "$i" -lt 18 ]; then bar_state=$BAR_YELLOW else bar_state=$BAR_RED fi printf '%b=%b' "$bar_state" "$RESET" else printf '%b·%b' "$BAR_DIM" "$RESET" fi i=$((i + 1)) done printf '%b] %b%d%%%b' "$LABEL_COLOR" "$bar_state" "$percent" "$RESET" } # Convert values from /proc/meminfo (KiB) to a compact human-readable size. human_kib() { awk -v kib="$1" 'BEGIN { if (kib >= 1048576) printf "%.0f GiB", kib / 1048576; else printf "%.0f MiB", kib / 1024; }' } # Normalize a sensor reading and reject malformed or implausible values. normalize_cpu_temperature() { printf '%s\n' "$1" | awk '{ value = $0 gsub(/[^0-9.]/, "", value) if (value ~ /^[0-9]+([.][0-9]+)?$/ && value + 0 < 200) { printf "%.1f", value exit } }' } # Convert a Linux thermal-zone value in millidegrees Celsius. read_millidegree_temperature() { [ -r "$1" ] || return 1 raw_temperature=$(cat "$1" 2>/dev/null) || return 1 case "$raw_temperature" in ''|*[!0-9]*) return 1 ;; esac awk -v value="$raw_temperature" 'BEGIN { temperature = value / 1000 if (temperature >= 0 && temperature < 200) printf "%.1f", temperature }' } # Read CPU temperature from common Raspberry Pi, Armbian, lm-sensors, or thermal-zone sources. get_cpu_temperature_c() { if command -v vcgencmd >/dev/null 2>&1; then raw_temperature=$(vcgencmd measure_temp 2>/dev/null | awk -F= 'NF > 1 {print $2; exit}') cpu_temperature=$(normalize_cpu_temperature "$raw_temperature") if [ -n "$cpu_temperature" ]; then printf '%s' "$cpu_temperature" return 0 fi fi if [ -r /etc/armbianmonitor/datasources/soctemp ]; then cpu_temperature=$(read_millidegree_temperature /etc/armbianmonitor/datasources/soctemp) if [ -n "$cpu_temperature" ]; then printf '%s' "$cpu_temperature" return 0 fi fi if command -v sensors >/dev/null 2>&1; then raw_temperature=$(LC_ALL=C sensors 2>/dev/null | awk ' /Package id 0:/ {print $4; exit} /Core 0:/ {print $3; exit} /Tdie:/ {print $2; exit} /Tctl:/ {print $2; exit} /junction:/ {print $2; exit} /cpu0_temp:/ {print $2; exit} ') cpu_temperature=$(normalize_cpu_temperature "$raw_temperature") if [ -n "$cpu_temperature" ]; then printf '%s' "$cpu_temperature" return 0 fi fi for hwmon_dir in /sys/class/hwmon/hwmon*; do [ -r "$hwmon_dir/name" ] || continue sensor_name=$(cat "$hwmon_dir/name" 2>/dev/null) case "$sensor_name" in k10temp|zenpower|coretemp) ;; *) continue ;; esac for label_file in "$hwmon_dir"/temp*_label; do [ -r "$label_file" ] || continue sensor_label=$(cat "$label_file" 2>/dev/null) case "$sensor_label" in Tctl|Tdie|Package*|Core*|CPU*|cpu*) temperature_file="${label_file%_label}_input" cpu_temperature=$(read_millidegree_temperature "$temperature_file") if [ -n "$cpu_temperature" ]; then printf '%s' "$cpu_temperature" return 0 fi ;; esac done for temperature_file in "$hwmon_dir"/temp*_input; do [ -r "$temperature_file" ] || continue cpu_temperature=$(read_millidegree_temperature "$temperature_file") if [ -n "$cpu_temperature" ]; then printf '%s' "$cpu_temperature" return 0 fi done done for temperature_file in /sys/class/thermal/thermal_zone*/temp; do [ -r "$temperature_file" ] || continue cpu_temperature=$(read_millidegree_temperature "$temperature_file") if [ -n "$cpu_temperature" ]; then printf '%s' "$cpu_temperature" return 0 fi done return 1 } # Request current weather and use the API-provided condition emoji when enabled. get_weather() { command -v curl >/dev/null 2>&1 || return 1 command -v jq >/dev/null 2>&1 || return 1 [ -r "$API_CURL_CONFIG" ] || return 1 payload=$(curl --config "$API_CURL_CONFIG" -fsS \ --connect-timeout 2 --max-time 4 -G \ --data-urlencode "city=$WEATHER_CITY" \ --data-urlencode "country=$WEATHER_COUNTRY" \ "$API_URL" 2>/dev/null) || return 1 printf '%s' "$payload" | jq -er \ --arg scale "$WEATHER_SCALE" \ --arg conditions "$WEATHER_CONDITIONS" ' if .success == true then . as $response | (if $scale == "F" then $response.current.temperature_f else $response.current.temperature_c end) as $temperature | if $conditions == "1" then "\($response.location.city) \($temperature | round)°\($scale) \($response.current.condition // "")" else "\($response.location.city) \($temperature | round)°\($scale) \($response.current.condition_emoji // "")" end else empty end ' 2>/dev/null } # Cache the rendered weather line locally to avoid one API request per login. weather_key=$(printf '%s|%s|%s|%s' "$WEATHER_CITY" "$WEATHER_COUNTRY" "$WEATHER_SCALE" "$WEATHER_CONDITIONS" | cksum | awk '{print $1}') weather_cache="/run/budyn-weather-${weather_key}.cache" weather='' if [ -r "$weather_cache" ]; then cache_mtime=$(stat -c %Y "$weather_cache" 2>/dev/null || printf '0') case "$cache_mtime" in ''|*[!0-9]*) cache_mtime=0 ;; esac cache_age=$(($(date +%s) - cache_mtime)) if [ "$cache_age" -ge 0 ] && [ "$cache_age" -lt "$WEATHER_CACHE_SECONDS" ]; then weather=$(cat "$weather_cache" 2>/dev/null) fi fi if [ -z "$weather" ]; then if weather=$(get_weather) && [ -n "$weather" ]; then cache_tmp=$(mktemp "/run/budyn-weather-${weather_key}.XXXXXX" 2>/dev/null || :) if [ -n "$cache_tmp" ]; then if printf '%s\n' "$weather" > "$cache_tmp" && chmod 644 "$cache_tmp" && mv -f "$cache_tmp" "$weather_cache"; then : else rm -f "$cache_tmp" fi fi else if ! command -v jq >/dev/null 2>&1; then weather='Weather API needs jq' elif [ ! -r "$API_CURL_CONFIG" ]; then weather='Weather API key config unavailable' else weather='Weather API unavailable' fi fi fi # Collect host, CPU, memory, storage, and uptime details. # Prefer the original login name when MOTD runs under sudo. login_user='' if command -v logname >/dev/null 2>&1; then login_user=$(logname 2>/dev/null || :) fi [ -n "$login_user" ] || login_user=${PAM_USER:-${SUDO_USER:-${LOGNAME:-${USER:-$(id -un)}}}} server_name=$(hostname -s 2>/dev/null || hostname) date_text=$(LC_ALL=C date '+%A %d %B %Y, %H:%M:%S') kernel=$(uname -r) architecture=$(uname -m) os_name='Linux' if [ -r /etc/os-release ]; then . /etc/os-release os_name=${PRETTY_NAME:-$os_name} fi cpu_model=$(awk -F ': ' '/^model name[[:space:]]*:/ {print $2; exit}' /proc/cpuinfo) [ -n "$cpu_model" ] || cpu_model=$(uname -m) logical_cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null || printf '1') cpu_sockets=1 cpu_cores=$logical_cpus if command -v lscpu >/dev/null 2>&1; then cpu_sockets=$(LC_ALL=C lscpu 2>/dev/null | awk -F: '$1 == "Socket(s)" {gsub(/[ \t]/, "", $2); print $2; exit}') cores_per_socket=$(LC_ALL=C lscpu 2>/dev/null | awk -F: '$1 == "Core(s) per socket" {gsub(/[ \t]/, "", $2); print $2; exit}') logical_cpus=$(LC_ALL=C lscpu 2>/dev/null | awk -F: '$1 == "CPU(s)" {gsub(/[ \t]/, "", $2); print $2; exit}') [ -n "$cpu_sockets" ] || cpu_sockets=1 [ -n "$cores_per_socket" ] || cores_per_socket=$logical_cpus [ -n "$logical_cpus" ] || logical_cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null || printf '1') cpu_cores=$((cpu_sockets * cores_per_socket)) fi load_average=$(awk '{print $1 " | " $2 " | " $3}' /proc/loadavg) process_count=$(ps -e --no-headers 2>/dev/null | wc -l | tr -d ' ') mem_total=$(awk '/^MemTotal:/ {print $2}' /proc/meminfo) mem_available=$(awk '/^MemAvailable:/ {print $2}' /proc/meminfo) swap_total=$(awk '/^SwapTotal:/ {print $2}' /proc/meminfo) swap_free=$(awk '/^SwapFree:/ {print $2}' /proc/meminfo) mem_used=$((mem_total - mem_available)) swap_used=$((swap_total - swap_free)) mem_percent=0 [ "$mem_total" -gt 0 ] && mem_percent=$((mem_used * 100 / mem_total)) disk_size=$(df -hP / 2>/dev/null | awk 'NR == 2 {print $2}') disk_used=$(df -hP / 2>/dev/null | awk 'NR == 2 {print $3}') disk_available=$(df -hP / 2>/dev/null | awk 'NR == 2 {print $4}') disk_percent=$(df -hP / 2>/dev/null | awk 'NR == 2 {gsub(/%/, "", $5); print $5}') inode_percent=$(df -iP / 2>/dev/null | awk 'NR == 2 {gsub(/%/, "", $5); print $5}') # Read boot time and format the elapsed uptime. uptime_seconds=$(awk '{print int($1)}' /proc/uptime) uptime_days=$((uptime_seconds / 86400)) uptime_hours=$(((uptime_seconds % 86400) / 3600)) uptime_minutes=$(((uptime_seconds % 3600) / 60)) boot_epoch=$(awk '$1 == "btime" {print $2}' /proc/stat) boot_date=$(LC_ALL=C date -d "@$boot_epoch" '+%d %b %Y, %H:%M:%S' 2>/dev/null || printf 'unknown') last_ip='N/A' last_when='First connection (or log was rotated)' if [ "$show_Last_Login" = on ]; then last_info='' if command -v wtmpdb >/dev/null 2>&1; then last_info=$(wtmpdb last "$login_user" --time-format iso -n 10 2>/dev/null | awk -v user="$login_user" '$1 == user && NF >= 4 {print $3, $4; exit}') fi if [ -z "$last_info" ] && command -v last >/dev/null 2>&1; then last_info=$(last "$login_user" --time-format iso -n 10 2>/dev/null | awk -v user="$login_user" '$1 == user && NF >= 4 {print $3, $4; exit}') fi if [ -z "$last_info" ] && command -v journalctl >/dev/null 2>&1; then last_info=$(journalctl -u ssh -u ssh.service -u sshd -u sshd.service \ --since '30 days ago' -o short-iso -g 'Accepted' --no-pager 2>/dev/null | awk -v user="$login_user" ' { for (i = 1; i <= NF - 3; i++) { if ($i == "for" && $(i + 1) == user && $(i + 2) == "from") { print $(i + 3), $1 } } } ' | tail -n 1) fi last_ip=$(printf '%s\n' "$last_info" | awk 'NF >= 2 {print $1}') last_timestamp=$(printf '%s\n' "$last_info" | awk 'NF >= 2 {print $2}') if [ -n "$last_timestamp" ]; then last_when=$(LC_ALL=C date -d "$last_timestamp" '+%b %e %T' 2>/dev/null || printf '%s' "$last_timestamp") fi case "$last_ip" in :[0-9]*|localhost) last_ip='Local user session' ;; esac [ -n "$last_ip" ] || last_ip='N/A' fi # Check Docker, active SSH sessions, failed logins, and network reachability. docker_running=0 docker_stopped=0 if [ "$show_Docker" = on ] && command -v docker >/dev/null 2>&1 && systemctl is-active --quiet docker 2>/dev/null; then docker_running=$(docker ps -q 2>/dev/null | wc -l | tr -d ' ') docker_stopped=$(docker ps -a -q --filter status=exited 2>/dev/null | wc -l | tr -d ' ') fi if [ "$show_SSH" = on ]; then ssh_active=$(who 2>/dev/null | grep -c 'pts/' || :) [ -n "$ssh_active" ] || ssh_active=0 today=$(LC_ALL=C date '+%b %e') failed_ssh=0 if [ -r /var/log/auth.log ]; then failed_ssh=$(grep "$today" /var/log/auth.log 2>/dev/null | grep -c 'Failed password' || :) elif command -v journalctl >/dev/null 2>&1; then failed_ssh=$(journalctl _COMM=sshd --since today 2>/dev/null | grep -c 'Failed password' || :) fi [ -n "$failed_ssh" ] || failed_ssh=0 fi ping_time() { ping -n -c 1 -W 1 "$1" 2>/dev/null | awk -F'time=' '/time=/ {split($2, value, " "); print value[1] "ms"; found=1} END {if (!found) print "Timeout"}' } if [ "$show_Ping" = on ]; then cloudflare_ping=$(ping_time 1.1.1.1) google_ping=$(ping_time 8.8.8.8) fi if [ "$show_IP" = on ]; then local_ip=$(ip -4 route get 1.1.1.1 2>/dev/null | awk '{for (i=1; i<=NF; i++) if ($i == "src") {print $(i+1); exit}}') [ -n "$local_ip" ] || local_ip='N/A' public_ipv6=$(ip -6 addr show scope global 2>/dev/null | awk '/inet6/ {sub(/\/.*/, "", $2); print $2; exit}') [ -n "$public_ipv6" ] || public_ipv6='N/A' fi # Read Fail2ban statistics only when explicitly enabled. if [ "$fail2ban" = on ]; then f2b_active='N/A' f2b_total='N/A' if [ -r "$FAIL2BAN_STATS_FILE" ] && command -v jq >/dev/null 2>&1; then f2b_active=$(jq -r '.total_active_bans // "N/A"' "$FAIL2BAN_STATS_FILE" 2>/dev/null) f2b_total=$(jq -r '.historical_total // "N/A"' "$FAIL2BAN_STATS_FILE" 2>/dev/null) elif command -v fail2ban-client >/dev/null 2>&1; then f2b_status=$(fail2ban-client status 2>/dev/null || :) f2b_jails=$(printf '%s\n' "$f2b_status" | awk -F: '/Jail list:/ {gsub(/,/, " ", $2); gsub(/^[ \t]+/, "", $2); print $2; exit}') if [ -n "$f2b_jails" ]; then f2b_active=0 f2b_total=0 for jail in $f2b_jails; do jail_status=$(fail2ban-client status "$jail" 2>/dev/null || :) jail_active=$(printf '%s\n' "$jail_status" | awk -F: '/Currently banned:/ {gsub(/[ \t]/, "", $2); print $2; exit}') jail_total=$(printf '%s\n' "$jail_status" | awk -F: '/Total banned:/ {gsub(/[ \t]/, "", $2); print $2; exit}') case "$jail_active" in ''|*[!0-9]*) jail_active=0 ;; esac case "$jail_total" in ''|*[!0-9]*) jail_total=0 ;; esac f2b_active=$((f2b_active + jail_active)) f2b_total=$((f2b_total + jail_total)) done fi fi fi quote_index=$((($(date +%s) / 86400) % 5)) case "$quote_index" in 0) quote='There is no place like 127.0.0.1' ;; 1) quote='Backup your data, or cry later.' ;; 2) quote='It works on my machine.' ;; 3) quote='Keep calm and check the logs.' ;; *) quote='Have you tried turning it off and on again?' ;; esac # Render the colored welcome block and the aligned penguin. printf '\n' paint "$MODEL_COLOR" " $cpu_model" printf '\n\n' welcome_line main_line "$date_text" "$DATE_COLOR" 1 main_line "$weather" "$WEATHER_COLOR" 2 main_line "Linux $kernel $architecture" "$SYSTEM_COLOR" 3 main_line "$os_name" "$SYSTEM_COLOR" 4 printf '\n' # Display the host resource and connection statistics in the original palette. stat_prefix 'Boot∙uptime' paint "$BOOT_DATE_COLOR" "$boot_date" printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$UPTIME_COLOR" "${uptime_days} days, ${uptime_hours} hrs, ${uptime_minutes} mins" printf '\n' stat_prefix 'CPU' paint "$CPU_VALUE_COLOR" "$cpu_sockets" printf ' ' paint "$CPU_TEXT_COLOR" 'physical CPU' printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$CPU_VALUE_COLOR" "$cpu_cores" printf ' ' paint "$CPU_TEXT_COLOR" 'cores' printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$CPU_VALUE_COLOR" "$logical_cpus" printf ' ' paint "$CPU_TEXT_COLOR" 'logical CPUs' printf '\n' stat_prefix 'Load' paint "$LOAD_VALUE_COLOR" "$load_average" printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$LOAD_VALUE_COLOR" "$process_count" printf ' ' paint "$LOAD_TEXT_COLOR" 'processes' case "$CPU_TEMP_SCALE" in F|f) CPU_TEMP_SCALE=F ;; *) CPU_TEMP_SCALE=C ;; esac cpu_temp_c=$(get_cpu_temperature_c || :) if [ -n "$cpu_temp_c" ]; then if [ "$CPU_TEMP_SCALE" = F ]; then cpu_temp_display=$(awk -v c="$cpu_temp_c" 'BEGIN {printf "%.1f", (9 / 5) * c + 32}') else cpu_temp_display=$cpu_temp_c fi printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$LOAD_VALUE_COLOR" "$cpu_temp_display°$CPU_TEMP_SCALE" fi printf '\n' stat_prefix 'Memory' progress_bar "$mem_percent" printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$MEMORY_TEXT_COLOR" 'Swap: ' paint "$MEMORY_VALUE_COLOR" "$(human_kib "$swap_used")" paint "$MEMORY_TEXT_COLOR" '/' paint "$MEMORY_VALUE_COLOR" "$(human_kib "$swap_total")" printf '\n' stat_prefix 'Memory' paint "$MEMORY_TEXT_COLOR" 'Total: ' paint "$MEMORY_VALUE_COLOR" "$(human_kib "$mem_total")" printf ' ' paint "$MEMORY_TEXT_COLOR" 'Used: ' paint "$MEMORY_VALUE_COLOR" "$(human_kib "$mem_used")" printf ' ' paint "$MEMORY_TEXT_COLOR" 'Available: ' paint "$MEMORY_VALUE_COLOR" "$(human_kib "$mem_available")" printf '\n' stat_prefix 'Storage' paint "$STORAGE_TEXT_COLOR" '∙Size: ' paint "$STORAGE_VALUE_COLOR" "$disk_size" printf ' ' paint "$STORAGE_TEXT_COLOR" 'Used: ' paint "$STORAGE_VALUE_COLOR" "$disk_used" printf ' ' paint "$STORAGE_TEXT_COLOR" 'Available: ' paint "$STORAGE_VALUE_COLOR" "$disk_available" printf '\n' stat_prefix 'Storage' progress_bar "${disk_percent:-0}" inode_pct=${inode_percent:-0} case "$inode_pct" in ''|*[!0-9]*) inode_pct=0 ;; esac inode_color=$BAR_GREEN if [ "$inode_pct" -ge 90 ]; then inode_color=$BAR_RED elif [ "$inode_pct" -ge 75 ]; then inode_color=$BAR_YELLOW fi printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$STORAGE_TEXT_COLOR" 'Inodes: ' printf '%b%s%%%b' "$inode_color" "$inode_pct" "$RESET" printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$STORAGE_TEXT_COLOR" 'Mnt: /' printf '\n' if [ "$show_Last_Login" = on ]; then stat_prefix 'Last login' paint "$LAST_LOGIN_IP_COLOR" "$last_ip" printf ' (' paint "$LAST_LOGIN_DATE_COLOR" "$last_when" printf ')\n' fi if [ "$show_Docker" = on ] && command -v docker >/dev/null 2>&1 && systemctl is-active --quiet docker 2>/dev/null; then stat_line 'Docker status' "$CUSTOM_STAT_COLOR" "Running: $docker_running ∗ Stopped: $docker_stopped" fi if [ "$show_SSH" = on ]; then stat_line 'SSH sessions' "$CUSTOM_STAT_COLOR" "Active: $ssh_active ∗ Failed today: $failed_ssh" fi if [ "$fail2ban" = on ]; then stat_line 'Fail2ban' "$CUSTOM_STAT_COLOR" "Active: $f2b_active ∗ Total: $f2b_total" fi if [ "$show_Ping" = on ]; then stat_line 'Gateway ping' "$CUSTOM_STAT_COLOR" "1.1.1.1: $cloudflare_ping ∗ 8.8.8.8: $google_ping" fi if [ "$show_IP" = on ]; then stat_prefix 'IP addresses' paint "$IP_COLOR" "$local_ip" printf ' %b∗%b ' "$ASTERISK_COLOR" "$RESET" paint "$IP_COLOR" "$public_ipv6" printf '\n' fi printf '\n' printf ' [ Aktualności i Bezpieczeństwo ]\n' printf ' %b»%b %s\n' "$FOOTER_GREEN" "$RESET" "$NEWS_RESET" printf ' %b»%b Stary czas przed restartem: %s\n' "$FOOTER_GREEN" "$RESET" "$NEWS_OLD_UPTIME" printf ' %b»%b Quote of the day: %b"%s"%b\n' "$FOOTER_GREEN" "$RESET" '\033[3;36m' "$quote" "$RESET" printf ' %b»%b Więcej informacji pod adresem: %b%s%b\n\n' "$FOOTER_GREEN" "$RESET" '\033[1;36m' "$INFO_URL" "$RESET"