Hi Stephan,

Would you please try the attached patch? This is against the init.d in
version 0.10.2-1.

Cheers!

On Tue, 2012-09-18 at 15:16 +0200, Stephan Seitz wrote:
> Package: mythtv-status
> Version: 0.10.2-1
> Severity: normal
> Tags: patch
> 
> Dear Maintainer,
> 
> since the last update of base-files the output of mythtv-status isn’t 
> found in /etc/motd anymore.
> 
> Checking /etc/init.d/motd and /etc/init.d/mythtv-status I think the 
> upgrade should go into /var/run/motd.dynamic which is read by pam_motd 
> together with the static /etc/motd.
> 
> I have change /etc/init.d/mythtv-status so that it works for me (patch 
> attached). Maybe it is useful for you as well.
> 
> Shade and sweet water!
> 
>       Stephan
> 
> -- System Information:
> Debian Release: wheezy/sid
>    APT prefers stable-updates
>    APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable')
> Architecture: amd64 (x86_64)
> Foreign Architectures: i386
> 
> Kernel: Linux 3.5.4-Dom0 (SMP w/2 CPU cores)
> Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> 
> Versions of packages mythtv-status depends on:
> ii  debconf [debconf-2.0]  1.5.46
> ii  libconfig-auto-perl    0.42-1
> ii  libdate-manip-perl     6.32-1
> ii  libmime-tools-perl     5.503-1
> ii  libsys-sigaction-perl  0.13-1
> ii  libwww-perl            6.04-1
> ii  libxml-libxml-perl     2.0001+dfsg-1
> ii  perl                   5.14.2-13
> 
> Versions of packages mythtv-status recommends:
> ii  libmythtv-perl    0.25.2-dmo3
> ii  libnet-upnp-perl  1.4.2-1
> 
> Versions of packages mythtv-status suggests:
> ii  molly-guard  0.4.5-1
> 
> -- debconf information excluded
> 

-- 
Andrew Ruthven
Wellington, New Zealand
At home: and...@etc.gen.nz |   linux.conf.au 2013
                           | Come join the party...
                           |  http://linux.conf.au
diff --git a/debian/init.d b/debian/init.d
index f7a083e..7b8c024 100644
--- a/debian/init.d
+++ b/debian/init.d
@@ -21,8 +21,8 @@
 # Provides:          mythtv-status
 # Required-Start:    $remote_fs
 # Required-Stop:     $remote_fs
-# Should-Start:      $named mythtv-backend
-# Should-Stop:       $named mythtv-backend
+# Should-Start:      $named mythtv-backend $motd
+# Should-Stop:       $named mythtv-backend $motd
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: Update the MOTD with the MythTV status
@@ -60,14 +60,18 @@ case "$1" in
     log_daemon_msg "Updating $DESC" "$NAME"
 
     # Just incase someone has removed their motd file.
-    [ -f /var/run/motd ] || touch /var/run/motd
-    [ -f /var/run/motd.orig ] || cp /var/run/motd /var/run/motd.orig
+    [ -f /var/run/motd.dynamic ] || touch /var/run/motd.dynamic
+    [ -f /var/run/motd.orig ] || cp /var/run/motd.dynamic /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
-      echo "Hey, $TEMPFILE already exists" 1>&2
-      ls -l /var/run/motd* 1>&2
-      ps -ef | grep mythtv-status 1>&2
-      cat /var/run/motd.new 1>&2
+      AGE=$(stat -c "%Z" $TEMPFILE);
+      if expr $AGE \> $(date +'%s') - 900
+      then
+        log_warning_msg "I think another $NAME is running."
+        exit 1
+      fi
     fi
 
     cp /var/run/motd.orig $TEMPFILE
@@ -77,12 +81,10 @@ case "$1" in
     $DAEMON $ARGS -h $HOST >> $TEMPFILE || ret=$?
     if [ $ret -eq 0 -o $ret -eq 1 ]; then
       if [ ! -f $TEMPFILE ]; then
-        # My file has gone away.  WTF?!  Spit out some debugging.
-	echo "Odd, $TEMPFILE has gone away.  Start: $date, End: $(date)" 1>&2
-        ls -l /var/run/motd* 1>&2
-        ps -ef | grep mythtv-status 1>&2
+        log_failure_msg "My temporary file has gone away, failed."
+        exit 1
       else
-        mv $TEMPFILE /var/run/motd
+        mv $TEMPFILE /var/run/motd.dynamic
       fi
       log_end_msg 0
     else
@@ -91,7 +93,7 @@ case "$1" in
     ;;
   stop)
     log_daemon_msg "Stopping $DESC" "$NAME"
-    [ -f /var/run/motd.orig ] && cp /var/run/motd.orig /var/run/motd
+    [ -f /var/run/motd.orig ] && cp /var/run/motd.orig /var/run/motd.dynamic
     rm /var/run/motd.orig
     log_end_msg 0
     ;;
@@ -100,11 +102,11 @@ case "$1" in
       log_failure_msg "$NAME is not running"
       exit 1
     fi
-    if [ ! -f /var/run/motd ]; then 
+    if [ ! -f /var/run/motd.dynamic ]; then 
       log_failure_msg "$NAME is not running (no motd file!)"
       exit 1
     fi
-    if [ $(date -d "15 minutes ago" +"%s") -gt $(stat -c "%Y" /var/run/motd) ]
+    if [ $(date -d "15 minutes ago" +"%s") -gt $(stat -c "%Y" /var/run/motd.dynamic) ]
     then
       log_failure_msg "$NAME is not running (motd file is stale)"
       exit 1

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to