# 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
# 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.
fi
# Have whatever the system motd contains before the MythTV content
- cp /var/run/motd.orig $TEMPFILE
+ cp $STUBFILE $TEMPFILE
fi