+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.
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
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