From 8fa65f7eeefe6c939e62ed55ab255706e2fd437e Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 20 Dec 2012 11:51:52 -0600
Subject: runit-scripts:  Dont' start a slave backend until a connection to
 master is established. -remove delay on the frontend service waiting on the
 backend.  The delay for mythfrontend has now been moved into frontend startup
 session script.

refs #886
---
 abs/core/runit-scripts/PKGBUILD                    |  2 +-
 .../runitscripts/services/frontend/run             |  8 ++--
 .../runitscripts/services/mythbackend/run          | 43 +++++++++++++++++-----
 3 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/abs/core/runit-scripts/PKGBUILD b/abs/core/runit-scripts/PKGBUILD
index 7750289..fa70061 100755
--- a/abs/core/runit-scripts/PKGBUILD
+++ b/abs/core/runit-scripts/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=runit-scripts
 pkgver=2.1.1
-pkgrel=99
+pkgrel=104
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license="BSD"
diff --git a/abs/core/runit-scripts/runitscripts/services/frontend/run b/abs/core/runit-scripts/runitscripts/services/frontend/run
index 7fb1795..3711058 100755
--- a/abs/core/runit-scripts/runitscripts/services/frontend/run
+++ b/abs/core/runit-scripts/runitscripts/services/frontend/run
@@ -15,10 +15,10 @@ touch /var/log/fluxbox.log
 chown mythtv:mythtv /var/log/fluxbox.log
 
 stat_runit "Starting LinHES frontend"
-if [ -e /service/mysql ]
-then
-  svwaitup -s 2 /service/mysql
-fi
+# if [ -e /service/mysql ]
+# then
+#   svwaitup -s 2 /service/mysql
+# fi
 
 #echo "Starting LinHES frontend" >/dev/tty1
 exec /bin/su - mythtv -l -c /usr/LH/bin/LinHES-start
diff --git a/abs/core/runit-scripts/runitscripts/services/mythbackend/run b/abs/core/runit-scripts/runitscripts/services/mythbackend/run
index 9ac0c6b..7bcf0a1 100755
--- a/abs/core/runit-scripts/runitscripts/services/mythbackend/run
+++ b/abs/core/runit-scripts/runitscripts/services/mythbackend/run
@@ -4,21 +4,26 @@ exec 2>&1
 export TERM=linux
 . /etc/rc.conf
 . /etc/rc.d/functions
+
 #wait for mysql
-/sbin/svwaitup -s 10 /service/mysql
-/sbin/svwaitup -s 2 /service/avahi
+if [ -e /service/mysql ]
+then
+    /sbin/svwaitup -s 10 /service/mysql
+fi
+
+if [ -e /service/avahi ]
+then
+    /sbin/svwaitup -s 2 /service/avahi
+fi
 
 #profile is here to setup LC_ALL/locale
 MYTH_RUN_STATUS="1"
-. /etc/profile 
+. /etc/profile
 
 MYTH_ARGS="-q --syslog local6"
 [ -f /etc/conf.d/mythbackend ] && . /etc/conf.d/mythbackend
 
 
-
-
-
 stat_runit "Scanning for new storage"
 MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/add_storage.py --report > /dev/null
 if [ -e /tmp/scan_report ]
@@ -33,7 +38,7 @@ then
 
 fi
 
-stat_runit "Starting MythBackend"
+
 export HOME=/root
 # 	if [ -f /tmp/debug ]
 # 		then
@@ -44,11 +49,31 @@ export HOME=/root
 # 			chown mythtv:mythtv /data/home/mythtv/gdb.txt.mythbackend
 # 			sleep 10
 #
-# 		else
+#   else
+            if [ x"$SystemType" = "xSlave_backend" ]
+            then
+                #do init check
+                MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/be_check.py
+                rc=$?
+                while [ $rc -ne 0 ]
+                do
+                    #msg "Waiting for connection to MythBackend"
+                    echo "    * Waiting for connection to primary MythBackend"
+                    MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/be_check.py
+                    rc=$?
+                    sleep 6
+                done
+                stat_runit "Starting Slave MythBackend"
+            else
+                stat_runit "Starting Primary MythBackend"
+            fi
+
+
+
             if pacman -Q mythtv | grep -q 0.24
             then
                 exec su mythtv -c "/usr/bin/mythbackend --logfile /var/log/mythtv/mythbackend.log"
             else
-			    exec su mythtv -c "/usr/bin/mythbackend -q --syslog local6"
+                exec su mythtv -c "/usr/bin/mythbackend -q --syslog local6"
             fi
 # 		fi
-- 
cgit v0.12

