From 11d14e8983c0efefedc169bb685f4103f44ebb28 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Sun, 14 Jun 2009 22:15:54 -0700
Subject: Added run and finish files for mediaserv.

---
 abs/extra-testing/mediaserv/PKGBUILD          | 8 +++++---
 abs/extra-testing/mediaserv/finish            | 8 ++++++++
 abs/extra-testing/mediaserv/mediaserv.install | 4 ++++
 abs/extra-testing/mediaserv/run               | 8 ++++++++
 4 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 abs/extra-testing/mediaserv/finish
 create mode 100644 abs/extra-testing/mediaserv/run

diff --git a/abs/extra-testing/mediaserv/PKGBUILD b/abs/extra-testing/mediaserv/PKGBUILD
index c117dbe..330b23b 100644
--- a/abs/extra-testing/mediaserv/PKGBUILD
+++ b/abs/extra-testing/mediaserv/PKGBUILD
@@ -3,23 +3,25 @@
 
 pkgname=mediaserv
 pkgver=0.05
-pkgrel=3
-pkgdesc="On-deman transcoding server for videos, targetting the Nokia Internet Tablets."
+pkgrel=4
+pkgdesc="On-demand transcoding server for videos, targetting the Nokia Internet Tablets."
 arch=('i686' 'x86_64')
 license=('ARTISTIC')
 depends=('tablet-encode' 'perl-xml-rss')
 install=(mediaserv.install)
 url="http://mediautils.garage.maemo.org/tablet-encode.html"
-source=(https://garage.maemo.org/frs/download.php/2632/mediaserv-0.05.tar.gz linhes-mediaserv.tar.bz2 mediaserv.no_daemon.patch)
+source=(https://garage.maemo.org/frs/download.php/2632/mediaserv-0.05.tar.gz linhes-mediaserv.tar.bz2 mediaserv.no_daemon.patch run finish)
 
 build() {
   cd ${srcdir}/mediaserv
   patch -Np1 -i ${startdir}/src/mediaserv.no_daemon.patch || return 1
   mkdir -p $startdir/pkg/usr/bin
+  mkdir -p $startdir/pkg/etc/sv/mediaserv/supervise
   mkdir -p $startdir/pkg/usr/share/doc/mediaserv
   mkdir -p $startdir/pkg/myth/mediaserv
   mkdir -p $startdir/pkg/myth/mediaserv/media
   install -D -m755 mediaserv $startdir/pkg/usr/bin
   cp README.txt $startdir/pkg/usr/share/doc/mediaserv
   cp -a ${srcdir}/.mediaserv/* ${pkgdir}/myth/mediaserv
+  install -D -m755 ${srcdir}/run ${srcdir}/finish $startdir/pkg/etc/sv/mediaserv
 }
diff --git a/abs/extra-testing/mediaserv/finish b/abs/extra-testing/mediaserv/finish
new file mode 100644
index 0000000..f424494
--- /dev/null
+++ b/abs/extra-testing/mediaserv/finish
@@ -0,0 +1,8 @@
+#!/bin/bash
+exec 2>&1
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+stat_runit "Stopping mediaserv"
+#wait
+exec /usr/bin/killall mediaserv
diff --git a/abs/extra-testing/mediaserv/mediaserv.install b/abs/extra-testing/mediaserv/mediaserv.install
index 6fe6f08..7a26077 100644
--- a/abs/extra-testing/mediaserv/mediaserv.install
+++ b/abs/extra-testing/mediaserv/mediaserv.install
@@ -4,6 +4,8 @@ post_install() {
   ln -s /myth/pretty /myth/mediaserv/media/tv
   ln -s /myth/video /myth/mediaserv/media/video
   chown -R mythtv.mythtv /myth/mediaserv
+  add_service.sh mediaserv
+  sv start mediaserv
 }
 # arg 1:  the new package version
 # arg 2:  the old package version
@@ -13,6 +15,8 @@ post_upgrade() {
 
 # arg 1:  the old package version
 post_remove() {
+	sv stop mediaserv
+	remove_service.sh mediaserv
 	rm -fr /home/mythtv/.mediaserv
 	rm -fr /myth/mediaserv
 }
diff --git a/abs/extra-testing/mediaserv/run b/abs/extra-testing/mediaserv/run
new file mode 100644
index 0000000..82a1705
--- /dev/null
+++ b/abs/extra-testing/mediaserv/run
@@ -0,0 +1,8 @@
+#!/bin/bash
+exec 2>&1
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+stat_runit "Starting mediaserv"
+exec su mythtv -c "/usr/bin/mediaserv"
+wait
-- 
cgit v0.12

