Add "do_build_watch"

This commit is contained in:
Jörn-Michael Miehe 2020-02-18 08:00:43 +01:00
parent 76aa31c0c6
commit 0022106d97
2 changed files with 19 additions and 14 deletions

View file

@ -15,7 +15,8 @@ g_lib=${g_bin/"bin"/"lib"}
source "${g_lib}/globals"
source "${g_lib}/logging"
source "${g_lib}/handle_inotify"
source "${g_lib}/main"
for plugin in "${g_lib}/plugins/"*".sh"; do
source "${plugin}"
done
@ -29,15 +30,4 @@ echo "Building everything in '${g_watchroot}'."
do_build_all
echo "Watching '${g_watchroot}'."
# setup inotify:
# -mrq monitor, recursive, quiet
# -e events
# --format %e eventlist csv, %w workdir, %f filename
inotifywait -mrq \
-e create -e delete -e moved_to -e close_write \
--format '%e %w%f' \
"${g_watchroot}" | \
\
while read NOTIFICATION; do
do_handle ${NOTIFICATION}
done
do_build_watch

View file

@ -1,7 +1,7 @@
#!/bin/bash
# process an inotify event
do_handle() { # $FLAGS $OBJECT
do_handle_inotify() { # $FLAGS $OBJECT
# extract params
local flags="$1"
shift 1
@ -130,4 +130,19 @@ do_build_all() { #
done
}
do_build_watch() { #
# setup inotify:
# -mrq monitor, recursive, quiet
# -e events
# --format %e eventlist csv, %w workdir, %f filename
inotifywait -mrq \
-e create -e delete -e moved_to -e close_write \
--format '%e %w%f' \
"${g_watchroot}" | \
\
while read NOTIFICATION; do
do_handle_inotify ${NOTIFICATION}
done
}
echo -n "main ... "