1 | #! /bin/sh |
---|
2 | # |
---|
3 | # mpd mpd global ring init script |
---|
4 | # |
---|
5 | # Written by Zach Lowry <zach@zachlowry.net>. |
---|
6 | # |
---|
7 | # Based on skeleton by Miquel van Smoorenburg and Ian Murdock |
---|
8 | |
---|
9 | PATH=/sbin:/bin:/usr/sbin:/usr/bin |
---|
10 | DAEMON=/usr/bin/mpd |
---|
11 | CONF=/etc/mpd.conf |
---|
12 | NAME=mpd |
---|
13 | DESC=mpd |
---|
14 | |
---|
15 | START="no" |
---|
16 | DEFAULTFILE=/etc/default/mpd |
---|
17 | |
---|
18 | if [ -f $DEFAULTFILE ]; then |
---|
19 | . $DEFAULTFILE |
---|
20 | fi |
---|
21 | |
---|
22 | # MPDOPTIONS="--daemon $MPDOPTIONS" |
---|
23 | |
---|
24 | if [ "$START" != "yes" ]; then |
---|
25 | echo "$DESC: disabled, see /etc/default/mpd" |
---|
26 | exit 0; |
---|
27 | fi |
---|
28 | |
---|
29 | test -f $DAEMON || exit 0 |
---|
30 | |
---|
31 | if [ ! -f $CONF ]; then |
---|
32 | echo "$DESC: $CONF not found, see 'man 3 mpd'" |
---|
33 | exit 0; |
---|
34 | fi |
---|
35 | |
---|
36 | set -e |
---|
37 | |
---|
38 | case "$1" in |
---|
39 | start) |
---|
40 | echo -n "Starting $DESC: " |
---|
41 | start-stop-daemon --start --make-pidfile --background --quiet --pidfile /var/run/$NAME.pid \ |
---|
42 | --exec $DAEMON -- $MPDOPTIONS |
---|
43 | echo "$NAME." |
---|
44 | ;; |
---|
45 | stop) |
---|
46 | echo -n "Stopping $DESC: " |
---|
47 | start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid |
---|
48 | echo "$NAME." |
---|
49 | ;; |
---|
50 | #reload) |
---|
51 | # |
---|
52 | # If the daemon can reload its config files on the fly |
---|
53 | # for example by sending it SIGHUP, do it here. |
---|
54 | # |
---|
55 | # If the daemon responds to changes in its config file |
---|
56 | # directly anyway, make this a do-nothing entry. |
---|
57 | # |
---|
58 | # echo "Reloading $DESC configuration files." |
---|
59 | # start-stop-daemon --stop --signal 1 --quiet --pidfile \ |
---|
60 | # /var/run/$NAME.pid --exec $DAEMON |
---|
61 | #;; |
---|
62 | restart|force-reload) |
---|
63 | # |
---|
64 | # If the "reload" option is implemented, move the "force-reload" |
---|
65 | # option to the "reload" entry above. If not, "force-reload" is |
---|
66 | # just the same as "restart". |
---|
67 | # |
---|
68 | echo -n "Restarting $DESC: " |
---|
69 | start-stop-daemon --oknodo --stop --quiet --pidfile \ |
---|
70 | /var/run/$NAME.pid |
---|
71 | sleep 1 |
---|
72 | start-stop-daemon --start --make-pidfile --background --quiet --pidfile \ |
---|
73 | /var/run/$NAME.pid --exec $DAEMON -- $MPDOPTIONS |
---|
74 | echo "$NAME." |
---|
75 | ;; |
---|
76 | *) |
---|
77 | N=/etc/init.d/$NAME |
---|
78 | echo "Usage: $N {start|stop}" >&2 |
---|
79 | exit 1 |
---|
80 | ;; |
---|
81 | esac |
---|
82 | |
---|
83 | exit 0 |
---|