summaryrefslogtreecommitdiff
path: root/media-sound/mpd/files/mpd-0.24.15.init
blob: 3fa24a8f10329e5934ecc75adff2dc067d7facc5 (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
#!/sbin/openrc-run
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

: ${MPD_CFGFILE:=/etc/mpd.conf}
: ${MPD_USER:=mpd}

description="Music Player Daemon"
command=/usr/bin/mpd
command_args="${MPD_EXTRA_ARGS} ${MPD_CFGFILE}"
command_args_foreground="--no-daemon"
command_user="${MPD_USER}"
required_files="${MPD_CFGFILE}"
supervisor="supervise-daemon"

extra_started_commands="reload"

depend() {
	need localmount
	use net netmount alsasound esound pulseaudio
}

start_pre() {
	# the log_file was owned by root with the initscript prior to 0.24.15
	# use checkpath as a workaround during migration because log_file is defined by default for everyone
	# ideally this should be removed later
	local log_file="/var/log/mpd/mpd.log"
	if [ -f "${log_file}" ]; then
		checkpath -f -m 644 -o "${MPD_USER}" "${log_file}"
	else
		return 0
	fi
}

reload() {
	ebegin "Reloading ${RC_SVCNAME}"
	supervise-daemon "${RC_SVCNAME}" --signal HUP
	eend $?
}