Add Debian packaging infrastructure
[headphoned] / debian / headphoned.zheadphoned.init
1 #! /bin/sh
2 #
3 # skeleton      example file to build /etc/init.d/ scripts.
4 #               This file should be used to construct scripts for /etc/init.d.
5 #
6 #               Written by Miquel van Smoorenburg <miquels@cistron.nl>.
7 #               Modified for Debian 
8 #               by Ian Murdock <imurdock@gnu.ai.mit.edu>.
9 #
10 # Version:      @(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
11 #
12
13 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
14 DAEMON=/usr/sbin/headphoned
15 NAME=headphoned
16 USER=user
17 DESC="Headphone daemon"
18
19 # XXX: The following is needed for the D-Bus connection to work
20 export DBUS_SESSION_BUS_ADDRESS='unix:path=/tmp/session_bus_socket'
21 # XXX end
22
23 test -x $DAEMON || exit 0
24
25 set -e
26
27 case "$1" in
28   start)
29         echo -n "Starting $DESC: "
30         start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
31                 -b --user $USER --chuid $USER --exec $DAEMON -- $DAEMON_OPTS
32         echo "$NAME."
33         ;;
34   stop)
35         echo -n "Stopping $DESC: "
36         _PIDS=`pidof $DAEMON || echo ""`
37         if [ "$_PIDS" != "" ]; then
38                 kill $_PIDS
39         fi
40         #start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
41         #       --user $USER --chuid $USER --exec $DAEMON
42         echo "$NAME."
43         ;;
44   reload)
45         #
46         #       If the daemon can reload its config files on the fly
47         #       for example by sending it SIGHUP, do it here.
48         #
49         #       If the daemon responds to changes in its config file
50         #       directly anyway, make this a do-nothing entry.
51         #
52         # echo "Reloading $DESC configuration files."
53         # start-stop-daemon --stop --signal 1 --quiet --pidfile \
54         #       /var/run/$NAME.pid --exec $DAEMON
55         ;;
56   force-reload)
57         #
58         #       If the "reload" option is implemented, move the "force-reload"
59         #       option to the "reload" entry above. If not, "force-reload" is
60         #       just the same as "restart" except that it does nothing if the
61         #   daemon isn't already running.
62         # check wether $DAEMON is running. If so, restart
63         #start-stop-daemon --stop --test --quiet --pidfile \
64         #       --user $USER --chuid $USER /var/run/$NAME.pid --exec $DAEMON \
65         #&& $0 restart \
66         #|| exit 0
67         ;;
68   restart)
69     echo -n "Restarting $DESC: "
70         _PIDS=`pidof $DAEMON || echo ""`
71         if [ "$_PIDS" != "" ]; then
72                 kill $_PIDS
73         fi
74         #start-stop-daemon --stop --quiet --pidfile \
75         #       --user $USER --chuid $USER /var/run/$NAME.pid --exec $DAEMON
76         sleep 1
77         start-stop-daemon --start --quiet --pidfile -b --user $USER \
78                 --chuid $USER /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
79         echo "$NAME."
80         ;;
81   *)
82         N=/etc/init.d/$NAME
83         # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
84         echo "Usage: $N {start|stop|restart|force-reload}" >&2
85         exit 1
86         ;;
87 esac
88
89 exit 0