From f974db507d6236cb82d3daf31073fcfe82bcf2ed Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Mon, 29 Oct 2012 17:56:39 -0500
Subject: runit-scripts:  make mythbackend wait on mysql.  mysql must be up for
 at least 5 seconds. mysql add a bash signal trap so that mysql will shut down
 correctly.  Without this mysql ignores the term signal which makes it unique
 in the unix world.

---
 abs/core/runit-scripts/PKGBUILD                              | 2 +-
 abs/core/runit-scripts/runitscripts/services/mysql/run       | 7 ++++++-
 abs/core/runit-scripts/runitscripts/services/mythbackend/run | 3 +++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/abs/core/runit-scripts/PKGBUILD b/abs/core/runit-scripts/PKGBUILD
index 581bf06..83530fe 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=77
+pkgrel=78
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license="BSD"
diff --git a/abs/core/runit-scripts/runitscripts/services/mysql/run b/abs/core/runit-scripts/runitscripts/services/mysql/run
index e9dc6f6..f078c87 100755
--- a/abs/core/runit-scripts/runitscripts/services/mysql/run
+++ b/abs/core/runit-scripts/runitscripts/services/mysql/run
@@ -35,5 +35,10 @@ if [ ! -d /var/run/mysqld ]; then
   mkdir -p /var/run/mysqld
   chown mysql /var/run/mysqld
 fi
-exec /usr/bin/mysqld_safe --user=mysql &>/dev/null 
+HOME=/etc/mysql/
+MYSQLADMIN='/usr/bin/mysqladmin'
 
+trap "$MYSQLADMIN shutdown" 0
+trap 'exit 2' 1 2 3 15
+
+/usr/bin/mysqld_safe --user=mysql & wait
diff --git a/abs/core/runit-scripts/runitscripts/services/mythbackend/run b/abs/core/runit-scripts/runitscripts/services/mythbackend/run
index 26dca04..937b267 100755
--- a/abs/core/runit-scripts/runitscripts/services/mythbackend/run
+++ b/abs/core/runit-scripts/runitscripts/services/mythbackend/run
@@ -4,6 +4,9 @@ exec 2>&1
 export TERM=linux
 . /etc/rc.conf
 . /etc/rc.d/functions
+#wait for mysql
+/sbin/svwaitup -s 5 /service/mysql
+
 #profile is here to setup LC_ALL/locale
 MYTH_RUN_STATUS="1"
 . /etc/profile 
-- 
cgit v0.12

