summaryrefslogtreecommitdiff
blob: 4f6c37ce400d617298c41c5c8c9e83f462708879 (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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
# Somehow based on init.d file shipped with mt-daapd itself.
#
# You can run multiple copies of this service just symlinking them to
# mt-daapd.<name>, then it will load /etc/mt-daapd.d/<name>.conf as config
# file.
# Remember to give them different logs and cache directories.
#
# The main instance (with no <name>) uses /etc/mt-daapd.conf

# Check for OpenRC/Baselayout 2 -- see bug #230917
if [ -f /lib/librc.so -o -f /etc/init.d/sysfs -o -f /lib/rc/version ]; then
	myservice=$RC_SVCNAME
fi

CONF="${myservice##*.}"
if [[ -n ${CONF} && ${myservice} != "mt-daapd" ]]; then
	PIDFILE="/var/run/mt-daapd.${CONF}.pid"
	CONFFILE="/etc/mt-daapd.d/${CONF}.conf"
else
	PIDFILE="/var/run/mt-daapd.pid"
	CONFFILE="/etc/mt-daapd.conf"
fi

depend() {
	need net
	#USEHOWL need mDNSResponderPosix
}

start() {
	ebegin "Starting mt-daapd DAAP server"
	start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
		--exec /usr/sbin/mt-daapd -- -P ${PIDFILE} -c ${CONFFILE}
	eend $?
}

stop() {
	ebegin "Stopping mt-daapd DAAP server"
	start-stop-daemon --stop --quiet --pidfile ${PIDFILE} --signal 2
	eend $?

	rm -f ${PIDFILE}
}