add custom motd

This commit is contained in:
Ludovic Cartier
2026-06-17 22:19:50 +02:00
parent ca9f50fa1c
commit 10b8f06c65
3 changed files with 28 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
date=`date`
load=`cat /proc/loadavg | awk '{print $1}'`
root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", "exit !$2;$3/$2*100") }'`
users=`users | wc -w`
time=`uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }'`
processes=`ps aux | wc -l`
ip=`/sbin/ifconfig $(/sbin/route | grep default | awk '{ print $8 }') | grep -E -o 'inet [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | cut -d' ' -f2`
figlet $(hostname)
echo
printf "System load:\t%s\tIP Address:\t%s\n" $load $ip
printf "Memory usage:\t%s\tSystem uptime:\t%s\n" $memory_usage "$time"
printf "Usage on /:\t%s\tSwap usage:\t%s\n" $root_usage $swap_usage
printf "Local Users:\t%s\tProcesses:\t%s\n" $users $processes
echo
+6
View File
@@ -1,4 +1,10 @@
---
- name: motd | copy custom motd
copy:
src: 11-custom
dest: /etc/update-motd.d/11-custom
mode: '0755'
- name: motd | copy reboot required script
copy:
src: 99-reboot-required
+1
View File
@@ -24,3 +24,4 @@
- telnet
- tmux
- vim
- figlet