summaryrefslogtreecommitdiff
blob: e7bbeb186e9363838c8cf06ee56e7fdd85251651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

description="MythTV backend recording daemon"
extra_commands="resched upnprebuild"
description_resched="Forces the recording scheduler to update"
description_upnprebuild="Rebuilds the UPnP media cache"

depend() {
	# mythbackend doesn't need to run on the same machine that
	# mysql runs on. so its use for that reason
	use logger net.lo mysql LCDd
}

start() {
	local logging=

	[ -z "${MYTHBACKEND_VERBOSE}" ] && \
		MYTHBACKEND_VERBOSE="general"
	[ -z "${MYTHBACKEND_LOGGING}" ] && \
		MYTHBACKEND_LOGGING="files"
	case "${MYTHBACKEND_LOGGING}" in
		database) logging="--enable-dblog" ;;
		syslog\ *) logging="--${MYTHBACKEND_LOGGING}" ;;
		files) logging="--logpath /var/log/mythtv" ;;
		console) logging="--nologserver" ;;
		*)
			eerror "Invalid MYTHBACKEND_LOGGING value"
			exit 1
			;;
	esac

	#fixes for bug #101308
	unset DISPLAY
	unset SESSION_MANAGER

	# Work around any strange permissions that may be on these files.
	[ "x${MYTHBACKEND_LOGGING}" = "xfiles" ] && \
		checkpath --dir --owner mythv:video --mode 0664 /var/log/mythtv
	checkpath --dir --owner mythv:video --mode 0664 /home/mythtv

	ebegin "Starting MythTV Backend"
	start-stop-daemon --start --quiet --exec /usr/bin/mythbackend \
                --pidfile /var/run/mythbackend.pid -- \
		--daemon --pidfile /var/run/mythbackend.pid --user mythtv:video \
		--verbose ${MYTHBACKEND_VERBOSE} \
		${logging} ${MYTHBACKEND_OPTS}
	eend $?
}

stop() {
	ebegin "Stopping MythTV Backend"
	start-stop-daemon --stop --retry 10 --progress \
		--pidfile=/var/run/mythbackend.pid
	eend $?
}

resched() {
	ebegin "Updating the recording scheduler"
	/usr/bin/mythbackend --resched
	eend $?
}

upnprebuild() {
	ebegin "Rebuilding UPnP media cache"
	/usr/bin/mythbackend --upnprebuild
	eend $?
}