From d383e18985ab0d72bb9a5e046775a64f54920ba5 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Fri, 7 Mar 2014 16:54:04 +0000
Subject: LinHES-system: linhes_update: check if started using
 mythfrontend-start just kill mythfrontend

mythfrontend-start is started from mythwelcome and if USR1 is used it ends mythfrontend-start which causes mythwelcome to accept remote commands and multiple mythfrontends will try to be started.
---
 abs/core/LinHES-system/PKGBUILD          |  6 +++---
 abs/core/LinHES-system/linhes_update.sh  | 18 ++++++++++++++++--
 abs/core/LinHES-system/linhes_update2.sh |  9 ++++++++-
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index 80874c6..7c1b968 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-system
 pkgver=8.1
-pkgrel=18
+pkgrel=19
 arch=('i686' 'x86_64')
 install=system.install
 pkgdesc="Everything that makes LinHES an automated system"
@@ -121,8 +121,8 @@ md5sums=('7ab2a2c643d2b286811d8303d08982ad'
          '34fc1f58ad1eabf4eff4979d420760c0'
          '1118e7982ba77cb5be9b2391b7cdfd38'
          'a94fe6d980f4b810f2e2ae5352084b39'
-         '24b18dd43b983748359f472ee70fe139'
-         '96b9e14b063e251fc3c2fe9f5b42a22e'
+         '384956b4fd9bf40907856bab0e67b169'
+         'f4ce577e2ab1b6dbf9def46a8ab86e2d'
          '28f29578e5b3ba84fdf2aa57cf475bcf'
          '4a1fda884dcd7d65fb2690fbdbd92a83'
          '2b7fe3b57592823a4c7e3ec132dcb7f4'
diff --git a/abs/core/LinHES-system/linhes_update.sh b/abs/core/LinHES-system/linhes_update.sh
index 21dfb6c..d563504 100644
--- a/abs/core/LinHES-system/linhes_update.sh
+++ b/abs/core/LinHES-system/linhes_update.sh
@@ -9,6 +9,17 @@ usage () {
     exit $1
 }
 
+restart_mfe () {
+    #check if started from mythfrontend-start and if so just kill mfe
+    #otherwise reload mfe
+    if [[ `pgrep -fx "/bin/bash /usr/LH/bin/mythfrontend-start"` ]]
+    then
+        killall mythfrontend
+    else
+        pkill -USR1 mythfrontend
+    fi
+}
+
 dsply ()  {
     if grep -q "Updates Available" /usr/share/mythtv/themes/defaultmenu/linhes.xml
     then
@@ -16,9 +27,10 @@ dsply ()  {
             msg_client.py --clear --tag "checkUpdates"
             msg_client.py --kill
             msg_client.py --msg "Updates available!\nGo to the Service Menu to install the updates.|middle"
+        else
+            restart_mfe
         fi
         echo "    Updates available!"
-        pkill -USR1 mythfrontend
 		exit
     else
         [ "$1" = false ] && { msg_client.py --msg "Checking for updates...|middle" --timeout 600 --tag "checkUpdates"; }
@@ -40,6 +52,8 @@ chck ()  {
             msg_client.py --clear --tag "checkUpdates"
             msg_client.py --kill
 		    msg_client.py --msg "No updates available.\nReturning to Main Menu.|middle"
+        else
+            restart_mfe
         fi
         echo "    No updates available."
 	else
@@ -109,4 +123,4 @@ shift $(($OPTIND - 1))
 
 dsply $SILENT
 chck $SILENT
-pkill -USR1 mythfrontend
+#pkill -USR1 mythfrontend
diff --git a/abs/core/LinHES-system/linhes_update2.sh b/abs/core/LinHES-system/linhes_update2.sh
index d1913d0..5c05c99 100644
--- a/abs/core/LinHES-system/linhes_update2.sh
+++ b/abs/core/LinHES-system/linhes_update2.sh
@@ -41,4 +41,11 @@ fi
 sudo sed -i '/LinHES UPDATE MESSAGE/c\        <!--LinHES UPDATE MESSAGE' /usr/share/mythtv/themes/LinHES/menu-ui.xml
 
 #reload theme
-pkill -USR1 mythfrontend
+#check if started from mythfrontend-start and if so just kill mfe
+#otherwise reload mfe
+if [[ `pgrep -fx "/bin/bash /usr/LH/bin/mythfrontend-start"` ]]
+then
+    killall mythfrontend
+else
+    pkill -USR1 mythfrontend
+fi
-- 
cgit v0.12