summaryrefslogtreecommitdiff
path: root/media-sound/owntone/files/owntone.initd
blob: ee99dae982b642614716da454a56af43136d2cc0 (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
#!/sbin/openrc-run
# Copyright 1999-2024 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

description="DAAP/DACP (iTunes), RSP and MPD server."

command="/usr/sbin/owntone"
pidfile="/run/owntone/${SVCNAME}.pid"
conffile="/etc/${SVCNAME}.conf"
user=${USER:-owntone}
group=${GROUP:-audio}

depend() {
	need net avahi-daemon
	use dns
}

start_pre() {
	mkdir -p "${pidfile%/*}"
	chown ${user}:${group} "${pidfile%/*}"
}

stop_post() {
	rm -f "${pidfile}"
}

start() {
	ebegin "Starting ${SVCNAME}"
	start-stop-daemon --start --pidfile "${pidfile}" \
		--user ${user} --group ${group} \
		--exec ${command} -- -P "${pidfile}" -c "${conffile}" \
		${EXTRA_OPTS}
	eend $?
}

stop() {
	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --exec ${command} --pidfile "${pidfile}"
	eend $?
}