diff options
Diffstat (limited to 'main/mpd/mpd.initd')
-rw-r--r-- | main/mpd/mpd.initd | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/main/mpd/mpd.initd b/main/mpd/mpd.initd new file mode 100644 index 0000000000..10601dc47d --- /dev/null +++ b/main/mpd/mpd.initd @@ -0,0 +1,44 @@ +#!/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") + pidfile=${pidfile:-/var/run/mpd/$NAME.pid} +} + +start() { + checkconfig || return 1 + get_pidfile + ebegin "Starting ${NAME}" + start-stop-daemon --start --quiet \ + --pidfile $pidfile\ + --exec ${DAEMON} -- ${MPD_OPTS} + eend $? +} + +stop() { + get_pidfile + ebegin "Stopping ${NAME}" + start-stop-daemon --stop --quiet \ + --pidfile $pidfile \ + --exec ${DAEMON} + eend $? +} + |