From 2cba9ba48a1bfddfa4effb1a6fe464d9dbf135bb Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sun, 30 Dec 2018 23:07:22 +1300 Subject: [PATCH] Support the 'new' update-motd.d system --- ChangeLog | 6 ++++++ bin/mythtv-update-motd | 30 +++++++++++++++++++----------- debian/changelog | 1 + debian/init.d | 5 +---- debian/install | 1 + 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 447e26f..3b316e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-12-30 Andrew Ruthven + Modify mythtv-update-motd to look to see if /etc/update-motd.d is + present, if it is, then generate MOTD content in a compatible fashion. + On Debian derived systems we now install a snippet into /etc/update-motd.d + to cat the generated file if it is present. + 2018-12-30 David Meritt Fix the output of Next Recording to never have negative numbers. diff --git a/bin/mythtv-update-motd b/bin/mythtv-update-motd index 3d5703b..0e2096a 100755 --- a/bin/mythtv-update-motd +++ b/bin/mythtv-update-motd @@ -13,27 +13,35 @@ then exit fi -# Debian Wheezy+ handles the MOTD differently. -[ -f /var/run/motd.dynamic ] && WORKFILE=/var/run/motd.dynamic +if [ -d /etc/update-motd.d ] +then + WORKFILE=/var/run/motd.mythtv-status + TEMPFILE=/var/run/motd.mythtv-status.new +else + # Debian Wheezy+ handles the MOTD differently. + [ -f /var/run/motd.dynamic ] && WORKFILE=/var/run/motd.dynamic -# Just incase someone has removed their motd file. -[ -f $WORKFILE ] || touch $WORKFILE -[ -f /var/run/motd.orig ] || cp $WORKFILE /var/run/motd.orig + # Just incase someone has removed their motd file. + [ -f $WORKFILE ] || touch $WORKFILE + [ -f /var/run/motd.orig ] || cp $WORKFILE /var/run/motd.orig -# If the tempfile is less than 15 minutes old, object, otherwise -# we'll assume that something went wrong and remove it. -if [ -f $TEMPFILE ]; then - AGE=$(stat -c "%Z" $TEMPFILE); + # If the tempfile is less than 15 minutes old, object, otherwise + # we'll assume that something went wrong and remove it. + if [ -f $TEMPFILE ]; then + AGE=$(stat -c "%Z" $TEMPFILE); if (( $AGE > $(date +'%s') - 900 )) then echo "I think another $NAME is running." exit 1 fi + fi + + [ ! -f /var/run/motd.orig ] && cp /var/run/motd /var/run/motd.orig + + cp /var/run/motd.orig /var/run/motd.new fi -[ ! -f /var/run/motd.orig ] && cp /var/run/motd /var/run/motd.orig -cp /var/run/motd.orig /var/run/motd.new ret=0 mythtv-status $ARGS -h $HOST >> $TEMPFILE 2> /dev/null || ret=$? if [ $ret -eq 0 -o $ret -eq 1 ]; then diff --git a/debian/changelog b/debian/changelog index 522891c..c968a88 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ mythtv-status (0.10.8-1.1) UNRELEASED; urgency=medium * New upstream release (Closes #853857). + * Install a snippet into /etc/update-motd.d (Closes #902684). -- Andrew Ruthven Mon, 12 Nov 2018 23:19:17 +1300 diff --git a/debian/init.d b/debian/init.d index 5111a17..6c8e951 100644 --- a/debian/init.d +++ b/debian/init.d @@ -75,13 +75,10 @@ case "$1" in log_daemon_msg "Stopping $DESC" "$NAME" [ -f /var/run/motd.orig ] && cp /var/run/motd.orig $WORKFILE rm /var/run/motd.orig 2> /dev/null || true + rm $TEMPFILE 2> /dev/null || true log_end_msg 0 ;; status) - if [ ! -f /var/run/motd.orig ]; then - log_failure_msg "$NAME is not running" - exit 1 - fi if [ ! -f $WORKFILE ]; then log_failure_msg "$NAME is not running (no motd file)!" exit 1 diff --git a/debian/install b/debian/install index 850b6ef..67d3033 100644 --- a/debian/install +++ b/debian/install @@ -3,4 +3,5 @@ bin/mythtv_recording_now usr/bin bin/mythtv_recording_soon usr/bin bin/mythtv-update-motd /usr/sbin molly-guard/40-mythtv-recording-soon etc/molly-guard/run.d +update-motd.d/50-mythtv-status etc/update-motd.d debian/lintian/overrides/mythtv-status usr/share/lintian/overrides -- 2.30.2