Changed the `-d' switch to `-D' in the init.d-files
[collectd.git] / debian / collectd.init.d
1 #!/bin/sh
2 #
3 # collectd      Initscript for collectd
4 #               http://verplant.org/collectd/
5 # Author:       Florian Forster <octo@verplant.org>
6 #
7
8 set -e
9
10 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
11 DESC="Statistics collection daemon"
12 NAME=collectd
13 DAEMON=/usr/sbin/$NAME
14 SCRIPTNAME=/etc/init.d/$NAME
15 ARGS=""
16
17 # Gracefully exit if the package has been removed.
18 test -x $DAEMON || exit 0
19
20 if [ -r /etc/default/$NAME ]
21 then
22         . /etc/default/$NAME
23 fi
24
25 if [ -n "$DATA_DIR" ]; then
26         ARGS="-D $DATA_DIR"
27 fi
28
29 if [ -n "$PING_HOST" ]; then
30         for HOST in $PING_HOST
31         do
32                 ARGS="$ARGS -p $HOST"
33         done
34 fi
35
36 #
37 #       Function that starts the daemon/service.
38 #
39 d_start() {
40         if [ "x$START_SERVER" = "xyes" ]
41         then
42                 $DAEMON -s $ARGS
43         fi
44         if [ "x$START_CLIENT" = "xyes" ]
45         then
46                 $DAEMON -c $ARGS
47         fi
48         if [ "x$START_SERVER" != "xyes" -a "x$START_CLIENT" != "xyes" ]
49         then
50                 start-stop-daemon --start --quiet --exec $DAEMON -- -l $ARGS
51         fi
52 }
53
54 #
55 #       Function that stops the daemon/service.
56 #
57 d_stop() {
58         start-stop-daemon --stop --quiet --exec $DAEMON
59 }
60
61 case "$1" in
62   start)
63         echo -n "Starting $DESC: $NAME"
64         d_start
65         echo "."
66         ;;
67   stop)
68         echo -n "Stopping $DESC: $NAME"
69         d_stop
70         echo "."
71         ;;
72   restart|force-reload)
73         echo -n "Restarting $DESC: $NAME"
74         d_stop
75         sleep 1
76         d_start
77         echo "."
78         ;;
79   *)
80         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
81         exit 1
82         ;;
83 esac
84
85 exit 0
86
87 # vim:syntax=sh