summaryrefslogtreecommitdiff
blob: 97aaf0a181c89f8a0079e3e732771167038c04e7 (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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-tv/mythtv/files/0.18-mythbackend.rc,v 1.1 2005/05/11 20:16:42 cardoe Exp $

depend() {
	need net
	use mysql
}

checkconfig() {
	for i in $(groups "${MYTH_USER/:*/}") ; do
		[[ "${i}" == "audio" ]] && audio="yes"
		[[ "${i}" == "video" ]] && video="yes"
	done

	if [ -z "${audio}" -o -z "${video}" ] ; then
		ewarn ""
		[[ -z "${audio}" ]] && \
			ewarn "${HILITE}${MYTH_USER/:*/}${NORMAL} is not in the audio group"
		[[ -z "${video}" ]] && \
			ewarn "${HILITE}${MYTH_USER/:*/}${NORMAL} is not in the video group"
		ewarn ""
		ewarn "insufficient permissions discovered"
		ewarn "mythbackend may not start correctly"
		ewarn ""
	fi
}

start() {
	[[ -z "${MYTH_USER}" ]] && MYTH_USER="nobody:nobody"
	[[ -z "${MYTH_LOG}" ]] && MYTH_LOG="/var/log/mythtv/mythbackend.log"
	[[ -z "${MYTH_PID}" ]] && MYTH_PID="/var/run/mythbackend.pid"
	[[ -z "${MYTH_WARN}" || "${MYTH_WARN}" == "yes" ]] && checkconfig
	[[ -z "${MYTH_NICE}" ]] && MYTH_NICE="0"
	[[ -z "${MYTH_VERBOSE}" ]] && MYTH_VERBOSE="none"

	HOME="$(dirname "${MYTH_PID}")"
	QTDIR=/usr/qt/3

	# Work around any strange permissions that may be on these files.
	chown -R "${MYTH_USER}" "$(dirname "${MYTH_LOG}")"
	chown -R "${MYTH_USER}" "$(dirname "${MYTH_PID}")"

	ebegin "Starting myth backend"
	start-stop-daemon --start --quiet --chuid "${MYTH_USER}" \
		--exec /usr/bin/mythbackend --nicelevel "${MYTH_NICE}" -- \
		--daemon --pidfile "${MYTH_PID}" --logfile "${MYTH_LOG}" \
		--verbose ${MYTH_VERBOSE}
	eend $?
}

stop () {
	[[ -z "${MYTH_PID}" ]] && MYTH_PID="/var/run/mythbackend.pid"

	ebegin "Stopping myth backend"
	start-stop-daemon --stop --quiet --pidfile="${MYTH_PID}"
	eend $?
}