Thursday, May 30, 2019

Daily Dharma, part Deux

Similar to my short-lived Twitter bot, I recently tweaked my virtual server's Message of the Day to dynamically display a verse from the Dhammapada on login, framed by diamonds using "boxes". This is a guide on how to achieve this on a Debian system.
Dharma Jewels
First, install "display-dhammapada" and "boxes" with apt.

Create a directory with the path "/etc/update-motd.d/" and add your scripts under that directory with names starting with priority numbers. For example, I have "20updates" in there. Here it is:

#!/bin/sh
echo `dhamma` | fold -w 25 -s | boxes -a hcvc -d diamonds
echo "date   is $( date   )"

Then, chmod a+x /etc/update-motd.d/*
Then, edit "/etc/pam.d/sshd" and find the line with "motd". Change the path to

session    optional     pam_motd.so  motd=/var/run/motd

That should do it!

Edit: It did, in fact, do the trick for a while. However, then the MOTD would no longer get updated. I fixed it by changing the line in "/etc/pam.d/sshd" to


session    optional     pam_motd.so  motd=/run/motd.dynamic

The last dynamically updated MOTD before the unexplained break was this:
All processes are impermanent. When one sees this with understanding, then one is disillusioned with the things of suffering. This is the Path of Purification.
So, do not be surprised when things don't last.

No comments:

Post a Comment