summaryrefslogtreecommitdiff
blob: b014edb771065016cd8364d690839ea0188d8d15 (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
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

depend() {
	need net
}

start() {
	ebegin "Starting MiniDLNA"
	local params=""
	local stop=0

	checkpath -q -d -m 0755 -o ${M_USER:-nobody}:${M_GROUP:-nogroup} /var/run/minidlna

	params="$params -P /var/run/minidlna/minidlna.pid"

	if [[ "${RESCAN}" = "true" || "${RESCAN}" = yes ]]; then
		params="$params -R"
	fi

	#set the config file and check if it exists
	if [ -z "${CONFIG}" ]; then
		if [ ! -f "/etc/minidlna.conf" ]; then
			ewarn "You did not set the config file correctly"
			stop=1
		fi
		params="$params -f /etc/minidlna.conf"
	else
		if [ ! -f "${CONFIG}" ]; then
			ewarn "The specified config file does not exist"
			stop=1
		fi
		params="$params -f ${CONFIG}"
	fi


	if [ $stop -eq 1 ]; then
		eend 1
	else
		start-stop-daemon --start \
			--user ${M_USER:-nobody} --group ${M_GROUP:-nogroup} \
			--exec /usr/sbin/minidlna -- ${params}
		eend $?
	fi
}

stop() {
	ebegin "Stopping MiniDLNA"
	start-stop-daemon --stop --quiet --exec /usr/sbin/minidlna
	eend $?
}