summaryrefslogtreecommitdiff
path: root/system/monit/rc.monit
blob: 740e0f6919da942f1efefee6789e3c9755756188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#
# Init file for Monit process monitor.
#
# Written by Dag Wieers <dag@wieers.com>.
# Adapted for Slackware by Eric Hameleers <alien@slackware.com>
#

### Default variables
CONFIG="/etc/monitrc"

[ -x /usr/bin/monit ] || exit 1
[ -r "$CONFIG" ] || exit 1

RETVAL=0
prog="monit"
desc="Process Monitor"

start() {
  echo "Starting $desc ($prog):  /etc/rc.d/rc.$prog start"
  $prog -c $CONFIG
  return $?
}

stop() {
  echo "Shutting down $desc ($prog)..."
  $prog -c $CONFIG quit
  return $?
}

restart() {
  stop
  sleep 2
  start
}

reload() {
  echo "Reloading $desc ($prog)"
  $prog -c $CONFIG reload
  return $?
}

status() {
  $prog -c $CONFIG status
  return $?
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  reload)
    reload
    ;;
  status)
    status
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|reload|status}"
esac