File: mt-daapd.init

package info (click to toggle)
mt-daapd 0.9~r1696.dfsg-6lenny3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,960 kB
  • ctags: 3,220
  • sloc: ansic: 25,552; sh: 9,055; perl: 454; xml: 339; makefile: 225
file content (77 lines) | stat: -rw-r--r-- 1,777 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh

### BEGIN INIT INFO
# Provides:          mt-daapd
# Required-Start:    $local_fs $remote_fs $network $time avahi
# Required-Stop:     $local_fs $remote_fs $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Multithreaded DAAP music server 
# Description:       mt-daapd, a.k.a. Firefly Media Server, is what
#                    most people will understand to be an iTunes share
#                    server. It uses the DAAP protocol, as iTunes does,
#                    and supports streaming MP3 and AAC natively. It can
#                    make use of a number of conversion methods to expose
#                    Ogg and FLAC files too.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mt-daapd
NAME=mt-daapd
DESC=mt-daapd

test -x $DAEMON || exit 0

# Include mt-daapd defaults if available
if [ -f /etc/default/mt-daapd ] ; then
	. /etc/default/mt-daapd
fi

set -e

stopd() {
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
	    --signal 2 --exec $DAEMON --oknodo
	echo "$NAME."
	counter=0
	seen=0
	while pidof mt-daapd >/dev/null && [ $counter -lt 15 ]; do
		if [ $seen -eq 0 ]; then
			echo -n "Waiting for mt-daapd to terminate..."
			seen=1
		fi
		
		counter=$(($counter + 1))
		echo -n "."
		sleep 1
	done
	echo "OK, all clear."
}

startd() {
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet -m --pidfile /var/run/$NAME.pid \
		--oknodo --exec $DAEMON -- $DAEMON_OPTS 2>/dev/null
	echo "$NAME."
}

case "$1" in
  start)
	startd
	;;
  stop)
	stopd
	;;
  restart|force-reload)
	stopd
	startd
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0