Utility functions to manage update-motd.d directory
Find a file
2025-11-08 02:28:30 +01:00
assets Designing template file, defining template source, copy_template function, edit command implementation of -c option (--create) 2025-10-05 19:52:15 +02:00
commands Correcting destintation file 2025-10-23 01:25:41 +02:00
lib Fix typo in shebang 2025-11-08 02:27:52 +01:00
README.txt Creating README.txt 2025-11-08 02:28:30 +01:00
update-motd Implementing call of move command 2025-10-23 01:25:41 +02:00

================================================================================
                                  update-motd

                      Manage /etc/update-motd.d directory
================================================================================

This is an utility for managing the update-motd directory.
Commands can be used to add, edit, show, delete and so on files in the
update-motd directory.

update-motd with motd for "message of the day" is a message written at the start
of any ssh login session. It can be used to notice the user with all sorts of
informations.

To show a message it is normally required to either:
  - Edit the /etc/motd file.
  - Add or edit a file in the /etc/update-motd.d directory.

The /etc/motd file is a single file and then is not recommended for maintenance,
prefer /etc/update-motd.d since it can stor multiple files ans show them in
a defined order.

On the other hand, files in /etc/update-motd.d directory are not simple text
files but executable ones. And so have to be written with commands to print
characters on screen.
For instance this can be done using the 'echo' command in bash. But it can be
annoying to prepend all text lines with 'echo' commands.

update-motd utility privides multiple commands to easily modify the message of
the day.

After installation type:
$ update-motd help

--------------------------------------------------------------------------------
                                 PREREQUISITES
--------------------------------------------------------------------------------

Clear the content of /etc/motd file or copy it somewhere to add it back
correctly to the /etc/update-motd.d directory. This utility consider
/etc/update-motd.d as the single source of the message of the day.

--------------------------------------------------------------------------------
                                    COMMANDS
--------------------------------------------------------------------------------

Here is a brief description of commands supported by the update-motd utility.
Type the following for further documentation.

$ update-motd help <command>

Commands:

- list : List files.
- show : Print content of files to stdin.
- add : Add files to be shown.
- edit : Use editor to modify content of a file.
- delete : Remove files.
- move : Rename and reorder files.

--------------------------------------------------------------------------------
                              ADDITIONAL FEATURES
--------------------------------------------------------------------------------

Priority management

To show messages in a specific order, it is possible to use priority management 
within update-motd commands.
For instance, it is possible to order added files with the -p argument that 
gives a priority to the added file. Or when a file with an already existing 
priority is added, its priority number can be incremented so it doesn't 
conflict.
Subsequently, some configuration options are available to manage priorities:
  - PRIORITY_LENGTH set the format, so you can keep an uniformised format.
  - PRIORITY_STEP set the increment when a priority conflict occurs. Putting 0
    disable this feature.

Template files

Files in the update-motd directory have to be executable files. It can be quite
annoying to not be able to just write plain text for the message of the day.
With the update-motd utility this can be done with templates. Using a
placeholder text can be inserted into a template and then copied in the 
update-motd directory. It can also be handy to prepare some formatting.
The basic template consist of a heredoc and a placeholder. This feature can be
configures with following options:
  - TEMPLATE_FILE is the location of the template file to use
  - TEMPLATE_PLACEHOLDER is the placeholder string that will be replaced with
    the text to add.