create a crond script to dynamic create an motd message to users
rc-service crond start && rc-update add crond
nano /etc/periodic/15min/motd
chmod a+x /etc/periodic/15min/motd
run-parts --test /etc/periodic/15min
Contents of /etc/periodic/15min/motd
#!/bin/sh
#. /etc/os-release
PRETTY_NAME=`awk -F= '$1=="PRETTY_NAME" { print $2 ;}' /etc/os-release | tr -d '"'`
VERSION_ID=`awk -F= '$1=="VERSION_ID" { print $2 ;}' /etc/os-release`
UPTIME_DAYS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 / 86400)
UPTIME_HOURS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 / 3600)
UPTIME_MINUTES=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 % 3600 / 60)
cat > /etc/motd << EOF
%+++++++++++++++++++++++++++++++ SERVER INFO ++++++++++++++++++++++++++++++++%
% %
Name: `hostname`
Uptime: $UPTIME_DAYS days, $UPTIME_HOURS hours, $UPTIME_MINUTES minutes
CPU: `cat /proc/cpuinfo | grep 'model name' | head -1 | cut -d':' -f2`
Memory: `free -m | head -n 2 | tail -n 1 | awk {'print $2'}`M
Swap: `free -m | tail -n 1 | awk {'print $2'}`M Disk: `df -h / | awk '{ a = $2 } END { print a }'`
Kernel: `uname -r`
Distro: $PRETTY_NAME
Version $VERSION_ID
CPU Load: `cat /proc/loadavg | awk '{print $1 ", " $2 ", " $3}'`
Free Memory: `free -m | head -n 2 | tail -n 1 | awk {'print $4'}`M
Free Swap: `free -m | tail -n 1 | awk {'print $4'}`M
Free Disk: `df -h / | awk '{ a = $2 } END { print a }'`
eth0 Address: `ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`
% %
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
EOF
This is the result:
cat /etc/motd
%+++++++++++++++++++++++++++++++ SERVER INFO ++++++++++++++++++++++++++++++++%
% %
Name: vcs
Uptime: 8 days, 18 hours, 45 minutes
CPU: Intel(R) Atom(TM) CPU D525 @ 1.80GHz
Memory: 3938M
Swap: 1023M Disk: 5.5T
Kernel: 4.14.63
Distro: Alpine Linux edge
Version 3.12_alpha20200428
CPU Load: 0.06, 0.02, 0.00
Free Memory: 2313M
Free Swap: 809M
Free Disk: 5.5T
eth0 Address: 192.168.1.74
% %
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
does it work though?