]> git.pld-linux.org Git - packages/monit.git/blob - monit.init
up to 5.9; update license; remove duplicate config
[packages/monit.git] / monit.init
1 #!/bin/sh
2 #
3 # monit         Monitoring daemon
4 #
5 # chkconfig:    345 99 01
6 # description:  Monitoring daemon
7 #
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 # Get service config
13 [ -f /etc/sysconfig/monit ] && . /etc/sysconfig/monit
14
15 checkconfig() {
16         local out
17         out=$(/usr/sbin/monit -c /etc/monitrc -t 2>&1)
18         ret=$?
19         if [ $ret != 0 ]; then
20                 echo >&2 "$out"
21                 exit 1
22         fi
23 }
24
25 start() {
26         # Check if the service is already running?
27         if [ -f /var/lock/subsys/monit ]; then
28                 msg_already_running monit
29                 return
30         fi
31
32         checkconfig
33         msg_starting monit
34         daemon --pidfile /var/run/monit.pid /usr/sbin/monit -c /etc/monitrc -s /var/run/monit.state $OPTIONS
35         RETVAL=$?
36         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/monit
37 }
38
39 stop() {
40         # Stop daemons.
41         if [ ! -f /var/lock/subsys/monit ]; then
42                 msg_not_running monit
43                 return
44         fi
45
46         msg_stopping monit
47         busy
48         /usr/sbin/monit -c /etc/monitrc quit
49         RETVAL=$?
50         [ $RETVAL -eq 0 ] && ok || fail
51         rm -f /var/lock/subsys/monit > /dev/null 2>&1
52 }
53
54 reload() {
55         if [ ! -f /var/lock/subsys/monit ]; then
56                 msg_not_running monit
57                 exit 7
58         fi
59
60         checkconfig
61         msg_reloading monit
62         busy
63         /usr/sbin/monit -c /etc/monitrc reload
64         RETVAL=$?
65         [ $RETVAL -eq 0 ] && ok || fail
66 }
67
68 RETVAL=0
69 # See how we were called.
70 case "$1" in
71   start)
72         start
73         ;;
74   stop)
75         stop
76         ;;
77   restart)
78         checkconfig
79         stop
80         start
81         ;;
82   reload|force-reload)
83         reload
84         ;;
85   checkconfig)
86         checkconfig
87         echo "Config check OK"
88         ;;
89   status)
90         status monit
91         monit -c /etc/monitrc status
92         exit $?
93         ;;
94   *)
95         msg_usage "$0 {start|stop|restart|reload|force-reload|checkconfig|status}"
96         exit 3
97 esac
98
99 exit $RETVAL
This page took 0.079097 seconds and 3 git commands to generate.