summaryrefslogtreecommitdiff
path: root/bin/ii-watch
blob: 0987656f3e0ad1b8efc312b6e43845690ab5cd5d (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
#!/bin/sh

# shellcheck disable=SC2119,SC2120

# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"

checksum=$(
  calculate_script_checksum
)

while pgrep -x 'ii' >/dev/null && \
  [ "$(calculate_script_checksum)" = "${checksum}" ]; do
  # this avoids missing modifications during our last execution
  if [ -z "${said}" ]; then
    # shellcheck disable=SC2046
    inotifywait -t 30 -e 'CLOSE_WRITE,CLOSE' -e 'CREATE,ISDIR' $(
      find "${irc_dir}" \
        -type f \
        -name 'out' -o \
        -type d
      ) || true
  fi
  said=$(
    "${base_dir}/bin/ii-answer"
  )
done