#!/bin/sh # /etc/rc.d/rc.mpd # Start/stop/restart the Music Player Daemon (MPD) MPD_BIN="/usr/bin/mpd" MPD_CONF="/etc/mpd.conf" mpd_start() { if [ -x "$MPD_BIN" ]; then if pgrep -f "$MPD_BIN $MPD_CONF$" > /dev/null; then echo "MPD ($MPD_CONF) is already running." else echo "Starting MPD: $MPD_BIN $MPD_CONF" "$MPD_BIN" "$MPD_CONF" fi fi } mpd_stop() { echo "Stopping MPD ($MPD_CONF)..." pkill -f "$MPD_BIN $MPD_CONF$" 2>/dev/null } mpd_restart() { mpd_stop sleep 1 mpd_start } case "$1" in 'start') mpd_start ;; 'stop') mpd_stop ;; 'restart') mpd_restart ;; *) echo "usage $0 start|stop|restart" ;; esac