aports/main/mpd/mpd.initd
Peter Bui c3b5cb847d main/mpd: fix pidfile, change to system user
1. Fix handling of pidfile (parsing and creation of directory on start)

2. Make mpd a system user (similar to minidlna)
2015-03-16 15:14:46 +00:00

44 lines
754 B
Plaintext

#!/sbin/runscript
# init.d file for music player daemon
NAME=mpd
DAEMON=/usr/bin/$NAME
CONF=/etc/mpd.conf
depend() {
need localmount
use net netmount nfsmount esound pulseaudio
after firewall
}
checkconfig() {
[ -f "$CONF" ] && return 0
eerror "configuration file $CONF is missing"
return 1
}
get_pidfile() {
pidfile=$(awk '$1 == "pid_file" { print $2 }' "$CONF" | sed 's/"//')
pidfile=${pidfile:-/var/run/mpd/$NAME.pid}
}
start() {
checkconfig || return 1
get_pidfile
checkpath --owner ${M_USER:-mpd}:${M_GROUP:-audio} \
--directory ${pidfile%/*}
ebegin "Starting ${NAME}"
start-stop-daemon --start --quiet \
--exec ${DAEMON} -- ${MPD_OPTS}
eend $?
}
stop() {
get_pidfile
ebegin "Stopping ${NAME}"
mpd --kill
eend $?
}