update-motd

Dynamically update /etc/motd without relying on pam_motd
git clone git://git.danielmoch.com/update-motd.git
Log | Files | Refs

commit b35349dc259044e837875766a903372e5444f733
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun,  3 Jun 2018 19:37:39 -0400

Initial commit

Diffstat:
Acontrib/archlinux/20-pacman | 18++++++++++++++++++
Acontrib/archlinux/motd.hook | 10++++++++++
Asrc/update-motd | 3+++
Asrc/update-motd.d/00-header | 7+++++++
Asrc/update-motd.d/10-fortune | 2++
Asrc/update-motd.d/99-footer | 2++
6 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/contrib/archlinux/20-pacman b/contrib/archlinux/20-pacman @@ -0,0 +1,18 @@ +#!/bin/sh +out=/run/motd.pacman +script=checkupdates + +if [ -f "$out" ] +then + echo + echo "`cat "$out" | wc -l` packages can be updated" + lastrun=`stat -c %Y "$out"` || lastrun=0 + expiration=`expr $lastrun + 3600` + + if [ `date +%s` -ge $expiration ] + then + $script > "$out" & + fi +else + $script > "$out" & +fi diff --git a/contrib/archlinux/motd.hook b/contrib/archlinux/motd.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Upgrade +Operation = Remove +Type = Package +Target = * + +[Action] +Description = Updating motd +When = PostTransaction +Exec = /etc/update-motd -f diff --git a/src/update-motd b/src/update-motd @@ -0,0 +1,3 @@ +#!/bin/sh +[ "$1" = "-f" ] && rm /run/motd* +run-parts /etc/update-motd.d > /run/motd.dynamic diff --git a/src/update-motd.d/00-header b/src/update-motd.d/00-header @@ -0,0 +1,7 @@ +#!/bin/sh +if [ -f /etc/os-release ] +then + . /etc/os-release + echo + echo "Welcome to $PRETTY_NAME" +fi diff --git a/src/update-motd.d/10-fortune b/src/update-motd.d/10-fortune @@ -0,0 +1,2 @@ +#!/bin/sh +[ -x /usr/bin/fortune ] && echo && /usr/bin/fortune diff --git a/src/update-motd.d/99-footer b/src/update-motd.d/99-footer @@ -0,0 +1,2 @@ +#!/bin/sh +echo