#!/usr/bin/env /lib/runit/invoke-run
#Copyright: 2023 Friedhelm Mehnert <friedhelm@friedhelms.net>
#           2026 Aitor <aitor@genuen.org>
#License: CC0-1.0

exec 2>&1

MPDCONF_FILE=/etc/mpd.conf
# Location can be changed within "/etc/default/mpd"
[ -f /etc/default/mpd ] && . /etc/default/mpd
if [ -n "${MPDCONF:-}" ]; then
	MPDCONF_FILE=$MPDCONF
fi

# The daemon refuses to start if it cannot create a pid file.
# We must provide a directory for this. Since we don't use the pid file
# for anything, we can ignore if the location has been changed in the
# config file and always use this compiled-in default.
install -m 755 --owner=mpd --group=audio -d /run/mpd

exec /usr/bin/mpd --no-daemon --stderr $MPDCONF_FILE
