When logging into an Ubuntu server you may have noticed the informative Message Of The Day (MOTD). This information is obtained and displayed using a couple of packages:
-
landscape-common: provides the core libraries of landscape-client, which can be used to manage systems using the web based Landscape application. The package includes the /usr/bin/landscape-sysinfo utility which is used to gather the information displayed in the MOTD.
-
update-notifier-common: is used to automatically update the MOTD via pam_motd module.
pam_motd executes the scripts in /etc/update-motd.d
in order based on the number
prepended to the script. The output of the scripts is written to /var/run/motd
, keeping the numerical order,
then concatenated with /etc/motd.tail
.
You can add your own dynamic information to the MOTD. For example, to add local weather information:
-
First, install the weather-util package:
sudo apt-get install weather-util
-
The weather utility uses METAR data from the National Oceanic and Atmospheric Administration and forecasts from the National Weather Service. In order to find local information you will need the 4-character ICAO location indicator. This can be determined by browsing to the National Weather Service site.
Although the National Weather Service is a United States government agency there are weather stations available world wide. However, local weather information for all locations outside the U.S. may not be available.
-
Create
/usr/local/bin/local-weather
, a simple shell script to use weather with your local ICAO indicator:#!/bin/sh # # # Prints the local weather information for the MOTD. # # # Replace KINT with your local weather station. # Local stations can be found here: http://www.weather.gov/tg/siteloc.shtml echo weather -i KINT echo
-
Make the script executable:
sudo chmod 755 /usr/local/bin/local-weather
-
Next, create a symlink to
/etc/update-motd.d/98-local-weather
:sudo ln -s /usr/local/bin/local-weather /etc/update-motd.d/98-local-weather
-
Finally, exit the server and re-login to view the new MOTD.
You should now be greeted with some useful information, and some information about the local weather that may not be quite so useful. Hopefully the local-weather example demonstrates the flexibility of pam_motd.