From d0791908cfb52bb69dadc578f6b8c38ceb1752bf Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 5 Jan 2019 11:28:21 +1300 Subject: [PATCH] Clean up what files we create and how we handle them. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Thanks for the tip from Göran Uddeborgthat I was double handlinga file. --- bin/mythtv-update-motd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/mythtv-update-motd b/bin/mythtv-update-motd index 0e3d38c..e31d042 100755 --- a/bin/mythtv-update-motd +++ b/bin/mythtv-update-motd @@ -15,14 +15,21 @@ fi if [ -d /etc/update-motd.d ] then + # We want to generate file which only contains the MythTV Status + # as a snippet in /etc/update-motd.d will cat this file. + WORKFILE=/var/run/motd.mythtv-status TEMPFILE=${WORKFILE}.new else + # We are going to generate an motd file to be used for the system, + # with the previous content first, then the MythTV Status. + # 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 + # Keep the original content around. [ -f /var/run/motd.orig ] || cp $WORKFILE /var/run/motd.orig # If the tempfile is less than 15 minutes old, object, otherwise @@ -36,9 +43,8 @@ else fi fi - [ ! -f /var/run/motd.orig ] && cp /var/run/motd /var/run/motd.orig - - cp /var/run/motd.orig /var/run/motd.new + # Have whatever the system motd contains before the MythTV content + cp /var/run/motd.orig $TEMPFILE fi -- 2.30.2