summaryrefslogtreecommitdiff
path: root/net/mpd/files/mpd.sh
blob: 01df6bfab322bbc345d4347da70dd52883249a73 (plain) (blame)
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
#!/bin/sh
# $FreeBSD$

DAEMON=/usr/local/sbin/mpd
PIDFILE=/var/run/mpd.pid

case "$1" in
start)
	if [ -f "${DAEMON}" -a -x "${DAEMON}" ]; then
		if [ -f "${PIDFILE}" ]; then
			echo ' mpd PID file found - not starting'
		else
			"${DAEMON}" -b -p "${PIDFILE}"
			echo -n ' mpd'
		fi
	else
		echo ' "${DAEMON}" executable not found - mpd not starting'
	fi
	;;
stop)
	if [ -f "${PIDFILE}" ]; then
		read -r pid junk < "${PIDFILE}"
		kill ${pid}
	else
		echo ' mpd PID file not found - not killing'
	fi
	;;
restart)
	$0 stop
	sleep 2
	$0 start
	;;
*)
	echo "usage: ${0##*/} {start|stop|restart}" >&2
	;;
esac