mpd.initd 750 Bytes
Newer Older
Natanael Copa's avatar
Natanael Copa committed
1 2 3 4 5
#!/sbin/runscript

# init.d file for music player daemon

NAME=mpd
6
DAEMON=/usr/bin/$NAME
Natanael Copa's avatar
Natanael Copa committed
7 8 9 10 11
CONF=/etc/mpd.conf

depend() {
	need localmount
	use net netmount nfsmount esound pulseaudio
12
	after firewall
Natanael Copa's avatar
Natanael Copa committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26
} 

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() {
27
	checkconfig || return 1
Natanael Copa's avatar
Natanael Copa committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
	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 $?
}