Skip to content

michaelheider/motd-info

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

124 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

motd Info

motd Info generates a dynamic motd via shell scripts. It is easily configurable.

Principles

motd Info follows the following principles:

  • information is displayed with as little characters as possible while still easily readable
    • this also means having sufficient blank space inbetween
  • bad values stand out more than good ones
  • dates are ISO-8601
  • times specify the time zone

Example

example

Setup

  1. Copy this folder to /usr/local/src/motd-info/. Perhaps exclude .git and similar. The target folder does not have to be owned by root. (Target location as per the Filesystem Hierarchy Standard.)
    • SCP to server: rsync -a --delete --exclude={".git",".gitignore",".shellcheckrc","example.txt","example.png"} --info=progress2 . user@server:/usr/local/src/motd-info
  2. create a symlink to the generate.sh script in the update-motd.d directory:
    sudo ln -s /usr/local/src/motd-info/generate.sh /etc/update-motd.d/09-motd-info
  3. check the static part of the motd in /etc/motd, remove unwanted parts (probably everyting, i.e. empty (not delete) the file)
  4. check what other motd scripts are in /etc/update-motd.d/ and delete the unwanted ones (probably all)
  5. configure config.txt to change the layout
  6. configure widgets
  7. if using lastlogins widget (default):
    • Disable sshd's last login prompt by setting the PrintLastLog flag to no in /etc/ssh/sshd_config (detailed implications explained below). Restart sshd with sudo systemctl restart sshd.
    • Unfortunately, there is no elegant way to remove the last login prompt on physical/virtual terminals (~/.hushlogin also hides motd).
  8. (optional) add a link into your home directory to always have access to the info: ln -s /usr/local/src/motd-info/generate.sh ~/motd-info

Widgets

Check the widget files for config options.

This chapter does not list all widgets, only ones that require special attention.

apt

You may want to install needsrestart to be notified of required restarts due to library upgrades. Check the widget for more info.

lastlogins

If you want to use the lastlogin widget:

  • lastlogins shows a list of the N most recently logged in users. This does not necessarily include you.
    • This is because motd is user agnostic.
  • motd may be pregenerated and cached, hence the info may be stale.
  • Disable sshd's last login prompt by setting the PrintLastLog flag to no in /etc/ssh/sshd_config.

lastexec

lastexec may be useful on systems where motd is cached (e.g. Ubuntu) to see how old the information is.

Development

Test Environment

  • test in motd environment: /usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ./generate.sh
    • actual motd environment is run as root
  • execute all system motd scripts: run-parts --lsbsysinit /etc/update-motd.d
  • execute all system motd scripts in motd environment: /usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin run-parts --lsbsysinit /etc/update-motd.d
    • actual motd environment is run as root

(taken from Stack Overflow)

Update Frequency

The motd displayed at login may not be up to date. Depending on the system, it is pre-generated and then cached for a while.

Ubuntu caches it. Proxmox does not. Any others I don't know.

Script Naming

The script (or symlink) in /etc/update-motd.d/ must have a filename that satisfies:

  • starting with a two digit number: dd-xxxxxx
  • only lower-case letters, digits, '-', '_'
  • no extension (as '.' is not allowed), no caps, 00-xxxxxxx

Check whether your script would run (outputs list of all scripts that would run without running them):
run-parts --test --lsbsysinit /etc/update-motd.d

Other motd

This motd was inspired by BDR's tinymod.

Other informational motd:

Further Reading

See motd.md.

About

dynamic motd

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 100.0%