From 3f17822ca63e6ad19ab02e3cdb6ecd2af65e16d9 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Mon, 19 Jan 2026 20:49:36 -0500 Subject: [PATCH] Update deploy-tws-motd --- deploy-tws-motd | 69 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/deploy-tws-motd b/deploy-tws-motd index 6747c70..9acd8ae 100644 --- a/deploy-tws-motd +++ b/deploy-tws-motd @@ -8,6 +8,17 @@ tws_short: "TWS" tasks: + - name: Remove static MOTD file (Debian default) + file: + path: /etc/motd + state: absent + + - name: Ensure dynamic MOTD symlink + file: + src: /run/motd.dynamic + dest: /etc/motd + state: link + - name: Check for default Ubuntu MOTD scripts stat: path: "/etc/update-motd.d/{{ item }}" @@ -29,35 +40,49 @@ mode: "0755" content: | #!/bin/bash + ORG="{{ tws_org }}" SHORT="{{ tws_short }}" - HOSTNAME="$(hostname)" + WIDTH=58 + + line() { + printf "║ %-*s ║\n" $((WIDTH-4)) "$1" + } + + border_top() { + printf "╔%s╗\n" "$(printf '═%.0s' $(seq 1 $((WIDTH-2))))" + } + + border_mid() { + printf "╠%s╣\n" "$(printf '═%.0s' $(seq 1 $((WIDTH-2))))" + } + + border_bot() { + printf "╚%s╝\n" "$(printf '═%.0s' $(seq 1 $((WIDTH-2))))" + } + + HOST="$(hostname)" OS="$(lsb_release -ds 2>/dev/null || grep PRETTY_NAME /etc/os-release | cut -d= -f2 | tr -d '"')" KERNEL="$(uname -r)" IP="$(hostname -I | awk '{print $1}')" UPTIME="$(uptime -p | sed 's/up //')" LOAD="$(awk '{print $1}' /proc/loadavg)" - - MEM_USED="$(free -h | awk '/Mem:/ {print $3}')" - MEM_TOTAL="$(free -h | awk '/Mem:/ {print $2}')" - - DISK_USED="$(df -h / | awk 'NR==2 {print $5}')" + MEM="$(free -h | awk '/Mem:/ {print $3 " / " $2}')" + DISK="$(df -h / | awk 'NR==2 {print $5 " used (/)"}')" USERS="$(who | wc -l)" - cat <