From 9e3312aa14c7e94b95c6cceba4ae8a0610e272c7 Mon Sep 17 00:00:00 2001
From: Michael Hanson <mihanson@linhes.org>
Date: Wed, 25 Jan 2012 22:45:15 +0000
Subject: runit-scripts: add mythdroid

---
 abs/core/runit-scripts/PKGBUILD                    |  2 +-
 .../runitscripts/services/mythbackend/log/run      |  8 ++++++++
 .../runitscripts/services/mythbackend/run          | 22 +++++-----------------
 .../runitscripts/services/mythdroid/finish         |  9 +++++++++
 .../runitscripts/services/mythdroid/run            | 16 ++++++++++++++++
 5 files changed, 39 insertions(+), 18 deletions(-)
 create mode 100755 abs/core/runit-scripts/runitscripts/services/mythbackend/log/run
 create mode 100755 abs/core/runit-scripts/runitscripts/services/mythdroid/finish
 create mode 100755 abs/core/runit-scripts/runitscripts/services/mythdroid/run

diff --git a/abs/core/runit-scripts/PKGBUILD b/abs/core/runit-scripts/PKGBUILD
index 877fe18..d00e353 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=49
+pkgrel=46
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license="BSD"
diff --git a/abs/core/runit-scripts/runitscripts/services/mythbackend/log/run b/abs/core/runit-scripts/runitscripts/services/mythbackend/log/run
new file mode 100755
index 0000000..17692a7
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/mythbackend/log/run
@@ -0,0 +1,8 @@
+#!/bin/sh
+exec 2>&1
+#export TERM=linux
+#. /etc/rc.conf
+#. /etc/rc.d/functions
+#stat_runit "Starting MythBackend logger"
+/usr/bin/logger -p local7.info -t mythbackend  
+
diff --git a/abs/core/runit-scripts/runitscripts/services/mythbackend/run b/abs/core/runit-scripts/runitscripts/services/mythbackend/run
index e3ef721..4bf54fb 100755
--- a/abs/core/runit-scripts/runitscripts/services/mythbackend/run
+++ b/abs/core/runit-scripts/runitscripts/services/mythbackend/run
@@ -1,33 +1,21 @@
 #!/bin/sh
 exec 2>&1
-#. /etc/profile
+. /etc/profile
 . /etc/systemconfig
 export TERM=linux
 . /etc/rc.conf
 . /etc/rc.d/functions
 
-
-
-stat_runit "Scanning for new storage"
-MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/add_storage.py --report > /dev/null
-if [ -e /tmp/scan_report ]
-then
-        echo "#####################################################"
-        echo "                New storage found                    "
-        echo ""
-        cat /tmp/scan_report
-        echo ""
-        echo "  run /usr/LH/bin/add_storage.py to make it available "
-        echo "#######################################################"
-
-fi
-
 stat_runit "Starting MythBackend"
 export HOME=/root
 if [ ! x$SystemType = xSlave_backend ]
 then
 	sv start mysql > /dev/null 2>/dev/null
+        #run mythfilldatabase
+	    #printhl "    Running mythfilldatabase"
+        #/usr/MythVantage/bin/initial_db_run &
 fi
+mkfifo /tmp/mbefifo >/dev/null 2>/dev/null
 #echo "Starting mythbackend"
 # 	if [ -f /tmp/debug ]
 # 		then
diff --git a/abs/core/runit-scripts/runitscripts/services/mythdroid/finish b/abs/core/runit-scripts/runitscripts/services/mythdroid/finish
new file mode 100755
index 0000000..c3d8b6b
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/mythdroid/finish
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+[ -f /etc/conf.d/mdd.conf ] && . /etc/conf.d/mdd.conf
+
+    PID=$(pidof -o %PPID -x /usr/bin/vendor_perl/mdd.pl)
+    [[ -n $PID ]] && kill $PID &> /dev/null
diff --git a/abs/core/runit-scripts/runitscripts/services/mythdroid/run b/abs/core/runit-scripts/runitscripts/services/mythdroid/run
new file mode 100755
index 0000000..fa2cb48
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/mythdroid/run
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+[ -f /etc/conf.d/mdd.conf ] && . /etc/conf.d/mdd.conf
+
+    stat_runit "Starting MythDroid daemon"
+
+    /sbin/chpst -u mythtv /usr/bin/vendor_perl/mdd.pl
+    PID=$(pidof -o %PPID -x /usr/bin/vendor_perl/mdd.pl)
+
+# Wait until daemon dies, else runit can't supervise us
+    while [ "`pidof -o %PPID -x /usr/bin/vendor_perl/mdd.pl`" == "$PID" ]; do
+      sleep 2
+    done
-- 
cgit v0.12

