110 lines
5.4 KiB
HTML
110 lines
5.4 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of update-motd</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>update-motd</H1>
|
|
Section: File Formats (5)<BR>Updated: 13 April 2010<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<P>
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
update-motd - dynamic MOTD generation
|
|
<P>
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>/etc/update-motd.d/*</B>
|
|
|
|
<P>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
UNIX/Linux system adminstrators often communicate important information to console and remote users by maintaining text in the file <I>/etc/motd</I>, which is displayed by the <B><A HREF="/cgi-bin/man/man2html?8+pam_motd">pam_motd</A></B>(8) module on interactive shell logins.
|
|
<P>
|
|
Traditionally, this file is static text, typically installed by the distribution and only updated on release upgrades, or overwritten by the local administrator with pertinent information.
|
|
<P>
|
|
Ubuntu introduced the <B>update-motd</B> framework, by which the <B><A HREF="/cgi-bin/man/man2html?5+motd">motd</A></B>(5) is dynamically assembled from a collection of scripts at login.
|
|
<P>
|
|
Executable scripts in <I>/etc/update-motd.d/*</I> are executed by <B><A HREF="/cgi-bin/man/man2html?8+pam_motd">pam_motd</A></B>(8) as the root user at each login, and this information is concatenated in <I>/run/motd.dynamic</I>. The order of script execution is determined by the <B><A HREF="/cgi-bin/man/man2html?8+run-parts">run-parts</A></B>(8) --lsbsysinit option (basically alphabetical order, with a few caveats).
|
|
<P>
|
|
On Ubuntu systems, <I>/etc/motd</I> is typically a symbolic link to <I>/run/motd.dynamic</I>.
|
|
<P>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>BEST PRACTICES</H2>
|
|
|
|
MOTD fragments must be scripts in <I>/etc/update-motd.d</I>, must be executable, and must emit information on standard out.
|
|
<P>
|
|
Scripts should be named named NN-xxxxxx where NN is a two digit number indicating their position in the MOTD, and xxxxxx is an appropriate name for the script.
|
|
<P>
|
|
Scripts must not have filename extensions, per <B><A HREF="/cgi-bin/man/man2html?8+run-parts">run-parts</A></B>(8) --lsbsysinit instructions.
|
|
<P>
|
|
Packages should add scripts directly into <I>/etc/update-motd.d</I>, rather than symlinks to other scripts, such that administrators can modify or remove these scripts and upgrades will not wipe the local changes. Consider using a simple shell script that simply calls <B>exec</B> on the external utility.
|
|
<P>
|
|
Long running operations (such as network calls) or resource intensive scripts should cache output, and only update that output if it is deemed expired. For instance:
|
|
<P>
|
|
<BR> /etc/update-motd.d/50-news
|
|
<BR> #!/bin/sh
|
|
<BR> out=/run/foo
|
|
<BR> script="w3m -dump <A HREF="http://news.google.com/">http://news.google.com/</A>"
|
|
<BR> if [ -f "$out" ]; then
|
|
<BR> # Output exists, print it
|
|
<BR> echo
|
|
<BR> cat "$out"
|
|
<BR> # See if it's expired, and background update
|
|
<BR> lastrun=$(stat -c %Y "$out") || lastrun=0
|
|
<BR> expiration=$(expr $lastrun + 86400)
|
|
<BR> if [ $(date +%s) -ge $expiration ]; then
|
|
<BR> $script > "$out" &
|
|
<BR> fi
|
|
<BR> else
|
|
<BR> # No cache at all, so update in the background
|
|
<BR> $script > "$out" &
|
|
<BR> fi
|
|
<P>
|
|
Scripts should emit a blank line before output, and end with a newline character. For instance:
|
|
<P>
|
|
<BR> /etc/update-motd/05-lsb-release
|
|
<BR> #!/bin/sh
|
|
<BR> echo
|
|
<BR> lsb-release -a
|
|
<P>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
<I>/etc/motd</I>, <I>/run/motd.dynamic</I>, <I>/etc/update-motd.d</I>
|
|
<P>
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?5+motd">motd</A></B>(5), <B><A HREF="/cgi-bin/man/man2html?8+pam_motd">pam_motd</A></B>(8), <B><A HREF="/cgi-bin/man/man2html?8+run-parts">run-parts</A></B>(8)
|
|
<P>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
This manpage and the update-motd framework was written by Dustin Kirkland <<A HREF="mailto:kirkland@canonical.com">kirkland@canonical.com</A>> for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 published by the Free Software Foundation.
|
|
<P>
|
|
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">BEST PRACTICES</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">FILES</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">SEE ALSO</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">AUTHOR</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:06 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|