aboutsummaryrefslogtreecommitdiff
path: root/system/incron/rc.incrond
blob: 752d930c46cc750936b4613b824065f682cca44b (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
#!/bin/sh
# Start/stop/restart the inotify cron daemon (incrond).

# Sanity check.  If /usr/sbin/incrond is missing then it
# doesn't make much sense to try to run this script:
if [ ! -x /usr/sbin/incrond ]; then
  printf "%s:  no /usr/sbin/incrond found (or not executable); cannot start.\n" "$0"
  exit 1
fi

# Check if incrond is running
incrond_running() {
  ps axc | egrep -q " incrond$"
}

# Start incrond.
incrond_start() {
  incrond_running && {
    echo "incrond is already running."
  } || {
    echo "Starting incrond:  /usr/sbin/incrond"
    /usr/sbin/incrond
  }
}

# Stop incrond (/usr/sbin/incrond):
incrond_stop() {
  incrond_running && {
    echo "Stopping incrond:  /usr/sbin/incrond -k"
    /usr/sbin/incrond -k
  } || {
    echo "incrond is not running."
  }
}

# Restart incrond:
incrond_restart() {
  incrond_stop
  incrond_start
}

case "$1" in
  'start')
    incrond_start
    ;;
  'stop')
    incrond_stop
    ;;
  'restart')
    incrond_restart
    ;;
  'status')
    incrond_running && {
      echo "incrond is running."
    } || {
      echo "No running incrond process."
    }

    ;;
  *)
    printf "usage:\n\t%s start|stop|restart|status\n" "$0"
esac