On Fri, Apr 2, 2021, at 23:09, Marko Tiikkaja wrote:
> Hi Joel
> 
> On Fri, Apr 2, 2021 at 11:47 PM Joel Jacobson <j...@compiler.org> wrote:
>> PostgreSQL has since long been suffering from the lack of a proper UNIX 
>> style motd (message of the day).
> 
> First of all, thanks for your work on this!  I think this is an important 
> feature to have, but I would love to see a way to have a set of strings from 
> which you choose a random one to display.  That way you could brighten your 
> day with random positive messages.
> 
> 
> -marko

Fun idea! I implemented it as a Perl script using the fortune command.

There are quite a lot of elephant jokes in the fortune database actually.

$ sudo apt install fortune-mod

$ crontab -l
0 0 * * * bash -c "/usr/local/bin/fortune_slony.pl | psql"

$ psql
NOTICE:
   ____  ______  ___
  /    )/      \/   \
(     / __    _\    )
  \    (/ o)  ( o)   )
   \_  (_  )   \ )  /
     \  /\_/    \)_/
      \/  //|  |\\
          v |  | v
            \__/
Q: Know what the difference between your latest project
and putting wings on an elephant is?
A: Who knows?  The elephant *might* fly, heh, heh...

/Joel
#!/usr/bin/perl
use strict;
use warnings;

my $slony = <<'SLONY'
E'\u001B[94m'
'\n   ____  ______  ___  '
'\n  /    )/      \\/   \\ '
'\n (     / __    _\\    )'
'\n  \\    (/ o)  ( o)   )'
'\n   \\_  (_  )   \\ )  / '
'\n     \\  /\\_/    \\)_/  '
'\n      \\/  //|  |\\\\    '
'\n          v |  | v    '
'\n            \\__/      '
'\u001b[0m'
SLONY
;

my $fortune = `/usr/games/fortune`;
$fortune =~ s/'/''/g;
$fortune =~ s/^(.*)$/'\\n$1'/gm;

print "ALTER SYSTEM SET motd TO $slony\n$fortune; SELECT pg_catalog.pg_reload_conf();";

Reply via email to