>>>>>>
<<<<<<
By default, Mythbuntu installs an init script in /etc/init.d, called
mythtv-status, and a similarly-named cron file in /etc/cron.d. The purpose of
these two files are to cause current MythTV status to be written to the message
of the day file (/var/run/motd) at regular intervals (every 10 minutes).
Unfortunately, the script, as installed, is broken. It fails to update the message of the day file and, if you enable sendmail for mail delivery, generates a windge email every cycle. Furthermore, the motd.new file that it creates isn't removed on shutdown, leading to the message of the day file being corrupted, if it is restarted. So, if you want actual status in your message of the day file, or don't want your mailbox filled up with 144 idiot messages every day, or want to be able to update the message of the day file, you need to fix the script. Here's our take on it:
#!/bin/sh # # Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org> # # This is free software; you may redistribute it and/or modify # it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2, # or (at your option) any later version. # # This is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License with # the Debian operating system, in /usr/share/common-licenses/GPL; if # not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA # ### BEGIN INIT INFO # Provides: mythtv-status # Required-Start: $mythtv-backend # Required-Stop: # Should-Start: $named # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Update the MOTD with the MythTV status # Description: Update the MOTD with the MythTV status ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/mythtv-status # Introduce the server's location here NAME=mythtv-status # Introduce the short server's name here DESC="MythTV Status" # Introduce a short description here test -x $DAEMON || exit 0 . /lib/lsb/init-functions # Include defaults if available if [ -f /etc/default/$NAME ] ; then . /etc/default/$NAME fi # Use this if you want the user to explicitly set 'RUN' in # /etc/default/ if [ "x$RUN" != "xyes" ] ; then log_failure_msg "$NAME disabled, please adjust the configuration to \ your needs " log_failure_msg "and then set RUN to 'yes' in /etc/default/$NAME to \ enable it." exit fi set -e case "$1" in start|reload|refresh|restart|force-reload) log_daemon_msg "Updating $DESC" "$NAME" [ ! -f /var/run/motd.orig ] && cp /var/run/motd /var/run/motd.orig $DAEMON $ARGS -h $HOST >/var/run/motd.new 2>/dev/null if [ -f /var/run/motd.new ]; then cat /var/run/motd.orig /var/run/motd.new >/var/run/motd 2>/dev/null touch "/var/run/$NAME" else if [ -f /var/run/motd.orig ]; then cp /var/run/motd.orig /var/run/motd else rm -f /var/run/motd 2>/dev/null fi rm -f "/var/run/$NAME" 2>/dev/null || true
fi
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
[ -f /var/run/motd.orig ] && cp /var/run/motd.orig /var/run/motd
rm -f /var/run/motd.orig 2>/dev/null
rm -f "/var/run/$NAME" 2>/dev/null || true
log_end_msg 0
;;
status)
if [ -f "/var/run/$NAME" ]; then
log_success_msg "$NAME is running" exit 0 else log_failure_msg "$NAME is not running" exit 1
fi
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|reload|refresh|status}" >&2
exit 1
;;
esac
exit 0