Changed the `-d' switch to `-D' in the init.d-files
[collectd.git] / contrib / init.d-rh7
1 #!/bin/bash
2
3 # Source function library.
4 . /etc/init.d/functions
5
6 RETVAL=0
7 ARGS=""
8 prog="collectd"
9
10 if [ -r /etc/default/$prog ]; then
11         . /etc/default/$prog
12 fi
13
14 if [ -n "$DATA_DIR" ]; then
15         ARGS="-D $DATA_DIR"
16 fi
17
18 if [ -n "$PING_HOST" ]; then
19         for HOST in $PING_HOST
20         do
21                 ARGS="$ARGS -p $HOST"
22         done
23 fi
24
25 start () {
26         if [ "x$START_SERVER" = "xyes" ]
27         then
28                 echo -n $"Starting $prog (server): "
29                 daemon /usr/sbin/collectd -s $ARGS
30                 RETVAL=$?
31                 echo
32                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
33         fi
34         if [ "x$START_CLIENT" = "xyes" ]
35         then
36                 echo -n $"Starting $prog (client): "
37                 daemon /usr/sbin/collectd -c $ARGS
38                 RETVAL=$?
39                 echo
40                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
41         fi
42         if [ "x$START_SERVER" != "xyes" -a "x$START_CLIENT" != "xyes" ]
43         then
44                 echo -n $"Starting $prog: "
45                 daemon /usr/sbin/collectd -l $ARGS
46                 RETVAL=$?
47                 echo
48                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
49         fi
50 }
51 stop () {
52         echo -n $"Stopping $prog: "
53         killproc $prog
54         RETVAL=$?
55         echo
56         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
57 }
58 # See how we were called.
59 case "$1" in
60   start)
61         start
62         ;;
63   stop)
64         stop
65         ;;
66   status)
67         status $prog
68         ;;
69   restart|reload)
70         stop
71         start
72         ;;
73   condrestart)
74         [ -f /var/lock/subsys/$prog ] && restart || :
75         ;;
76   *)
77         echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
78         exit 1
79 esac
80
81 exit $?
82
83 # vim:syntax=sh