From e235a08c001227e1258b4c23b1c1e9bbe63d3256 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 21 Sep 2012 10:12:58 -0500
Subject: LinHES-config:  backend_control.sh   add the ability to detect if
 func failed and attempt to display the msg using local msg_client.py

---
 abs/core/LinHES-config/PKGBUILD           |  4 +-
 abs/core/LinHES-config/backend_control.sh | 66 ++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index e1879b9..a5b0db5 100755
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=2.3
-pkgrel=140
+pkgrel=141
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev LinHes-config )
 pkgdesc="Install and configure your system"
 depends=('bc' 'libstatgrab'  'mysql-python' 'expect' 'curl' 'dnsutils' 'parted'
@@ -169,4 +169,4 @@ md5sums=('d27979591231e647f59c23ae18a3d37b'
          '6ec39b010c0ed8901ea896c7e153d330'
          '3866086e6af5e3528a66eff492f2f4dd'
          'c9279fa095af624ee3d9bc75d3328360'
-         '66a5e2dd3e51d11a93a17f7c01a8708f')
+         'a0df3d90e4a0da6781e45414a5f1b754')
diff --git a/abs/core/LinHES-config/backend_control.sh b/abs/core/LinHES-config/backend_control.sh
index 24c6551..07ff162 100755
--- a/abs/core/LinHES-config/backend_control.sh
+++ b/abs/core/LinHES-config/backend_control.sh
@@ -6,39 +6,61 @@ COMMAND=$1
 BETYPE=$2
 eval LAST=\$$#
 dbhost=`echo $LAST`
-
-
+hostname=`hostname`
 MESSAGE=""
+
 case $COMMAND in
-	stop)   MESSAGE=`/usr/bin/curl http://$dbhost:1337/bestop.cgi 2>/dev/null`
+    stop)   MESSAGE=`/usr/bin/curl http://$dbhost:1337/bestop.cgi 2>/dev/null`
             rc=$?
+
             if [ $rc != 0 ]
             then
                 lh_message.sh "Could not stop the backend."
+            else
+                echo "$MESSAGE" | grep -q "'$hostname': 'Message delivered'"
+                rc=$?
+                if [ $rc != 0 ]
+                then
+                    msg_client.py "* Backend Stopped" > /dev/null
+                fi
             fi
-		;;
+        ;;
 
-	start )
-		MESSAGE=`/usr/bin/curl http://$dbhost:1337/bestart.cgi 2>/dev/null`
-		rc=$?
-		if [ $rc != 0 ]
-		then
+    start )
+        MESSAGE=`/usr/bin/curl http://$dbhost:1337/bestart.cgi 2>/dev/null`
+        rc=$?
+        if [ $rc != 0 ]
+        then
             lh_message.sh "Could not start the backend"
-		fi
-       		;;
+        else
+            echo "$MESSAGE" | grep -q "'$hostname': 'Message delivered'"
+            rc=$?
+            if [ $rc != 0 ]
+            then
+                msg_client.py "* Backend Started" > /dev/null
+            fi
+        fi
+        ;;
 
-	restart)
-		/usr/MythVantage/bin/backend_control.sh stop $dbhost
-		sleep 2
-		/usr/MythVantage/bin/backend_control.sh start $dbhost
+    restart)
+        /usr/MythVantage/bin/backend_control.sh stop $dbhost
+        sleep 2
+        /usr/MythVantage/bin/backend_control.sh start $dbhost
+        ;;
 
-		;;
-	clearcache)
-		MESSAGE2=`/usr/bin/curl http://$dbhost:1337/beclear.cgi 2>/dev/null`
-		rc=$?
-		if [ $rc != 0 ]
-		then
+    clearcache)
+        MESSAGE2=`/usr/bin/curl http://$dbhost:1337/beclear.cgi 2>/dev/null`
+        rc=$?
+        if [ $rc != 0 ]
+        then
             lh_message.sh "Could not clear the cache"
-		fi
+        else
+            echo "$MESSAGE" | grep -q "'$hostname': 'Message delivered'"
+            rc=$?
+            if [ $rc != 0 ]
+            then
+                msg_client.py "* cache cleared" > /dev/null
+            fi
+        fi
 esac
 
-- 
cgit v0.12