]> TLD Linux GIT Repositories - packages/rrdtool.git/blob - rrdcached.init
3cf141799c8337c8c483462a30ad33526b719181
[packages/rrdtool.git] / rrdcached.init
1 #!/bin/sh
2 #
3 # rrdcached        This shell script takes care of starting and stopping
4 #                  the rrdcached.
5 #
6 # chkconfig: 2345 19 81
7 # description: It comes by night and sucks the vital essence from your computers.
8 #
9
10 # Source function library
11 . /etc/rc.d/init.d/functions
12
13 [ -f /etc/sysconfig/rrdcached ] && . /etc/sysconfig/rrdcached
14
15 # Set defaults if not defined in service config file
16 RRDCACHED_WRITE_TIMEOUT=${RRDCACHED_WRITE_TIMEOUT:-300}
17 RRDCACHED_WRITE_DELAY=${RRDCACHED_WRITE_DELAY:-180}
18 RRDCACHED_WRITE_THREADS=${RRDCACHED_WRITE_THREADS:-4}
19 RRDCACHED_PID_FILE="/var/run/rrdcached.pid"
20 RRDCACHED_SOCKET="/var/run/rrdcached.sock"
21
22 start() {
23         # Check if the service is already running?
24         if [ -f /var/lock/subsys/rrdcached ]; then
25                 msg_already_running "rrdcached"
26                 return
27         fi
28
29         msg_starting "rrdcached"
30         daemon /usr/bin/rrdcached -m 0660 -w ${RRDCACHED_WRITE_TIMEOUT} -z ${RRDCACHED_WRITE_DELAY} -t ${RRDCACHED_WRITE_THREADS} -p ${RRDCACHED_PID_FILE} -l ${RRDCACHED_SOCKET}
31         RETVAL=$?
32         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rrdcached
33 }
34
35 stop() {
36         if [ ! -f /var/lock/subsys/rrdcached ]; then
37                 msg_not_running "rrdcached"
38                 return
39         fi
40
41         # Stop daemons.
42         msg_stopping "rrdcached"
43         killproc /usr/sbin/rrdcached
44         rm -f /var/lock/subsys/rrdcached
45 }
46
47 condrestart() {
48         if [ ! -f /var/lock/subsys/rrdcached ]; then
49                 msg_not_running "rrdcached"
50                 RETVAL=$1
51                 return
52         fi
53
54         stop
55         start
56 }
57
58 case "$1" in
59   start)
60         start
61         ;;
62   stop)
63         stop
64         ;;
65   restart)
66         stop
67         start
68         ;;
69   status)
70         status rrdcached
71         RETVAL=$?
72         ;;
73 *)
74         msg_usage "$0 {start|stop|restart|status}"
75         exit 3
76         ;;
77 esac
78 exit $RETVAL