From a6e08cc67c0d6a3d9e5d97f27f95ac208a435644 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Fri, 11 Jan 2019 23:56:05 +1300 Subject: [PATCH] Add support for Fedora --- bin/mythtv-update-motd | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/bin/mythtv-update-motd b/bin/mythtv-update-motd index 6b33ef2..a56adc0 100755 --- a/bin/mythtv-update-motd +++ b/bin/mythtv-update-motd @@ -3,16 +3,21 @@ # Run mythtv-status to update the MOTD. NAME=mythtv-update-motd -WORKFILE=/var/run/motd -TEMPFILE=/var/run/motd.mythtv-status -. /etc/default/mythtv-status +# Debian style +[ -r /etc/default/mythtv-status ] && . /etc/default/mythtv-status +# Fedora style +[ -r /etc/sysconfig/mythtv-status ] && . /etc/sysconfig/mythtv-status if [ x$UPDATE_MOTD != xyes -o -f /var/lib/mythtv-status/motd_update_disabled ] then exit fi +WORKFILE=/var/run/motd +STUBFILE=/var/run/motd.orig +TEMPFILE=/var/run/motd.mythtv-status + if [ -d /etc/update-motd.d ] then # We want to generate file which only contains the MythTV Status @@ -24,13 +29,28 @@ 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 + if [ -f /etc/os-release ] + then + DISTRO=(grep ^ID= /etc/os-release | awk -F= '{ print $2 }') + else + DISTRO='unknown' + fi + + if [ $DISTRO = 'debian' ] + then + # Debian Wheezy+ handles the MOTD differently. + [ -f /var/run/motd.dynamic ] && WORKFILE=/var/run/motd.dynamic + elif [ $DISTRO eq 'fedora' ] + then + WORKFILE=/etc/motd + STUBFILE=/etc/motd.stub + TEMPFILE=/etc/motd.mythtv-status + fi # 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 + [ -f $STUBFILE ] || cp $WORKFILE $STUBFILE # If the tempfile is less than 15 minutes old, object, otherwise # we'll assume that something went wrong and remove it. @@ -44,7 +64,7 @@ else fi # Have whatever the system motd contains before the MythTV content - cp /var/run/motd.orig $TEMPFILE + cp $STUBFILE $TEMPFILE fi -- 2.30.2