Tutorial: motd

Looking forward to some new motd ideas.

My current motd:

2r2vjad.jpg

You need three components:

  • update-motd

    apt-get install update-motd
    

    You can modify every part of the motd by editing the files in /etc/update-motd.d

  • toilet

    apt-get install toilet
    
    toilet -f pagga system
    

    It is a small tool for ascii art.

    Following fonts are currently supported: http://caca.zoy.org/browser/toilet/trunk/fonts

  • weather

    apt-get install weather
    

    It will display the current weather informations on a defined weather station.

    weather -i ESSB
    

    You can go to the webpage of NOAA to find your weather station of choice: http://www.nws.noaa.gov/tg/siteloc.shtml

For the current system status I am using landscape-sysinfo from the package landscape-common:

#!/bin/sh
cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
[ "$cores" -eq "0" ] && cores=1
threshold="${cores:-1}.0"
if [ $(echo "`cut -f1 -d ' ' /proc/loadavg` < $threshold" | bc) -eq 1 ]; then
    echo
    echo -n "  System information as of "
    /bin/date
    echo
    /usr/bin/landscape-sysinfo
else
    echo
    echo " System information disabled due to load higher than $threshold"
fi

You can check the user id too:

if (( $(id -u) == 0 ))
then
echo "welcome root"
fi