Skip to content

Activate monitoring mode in inotifywait #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions scripts/inotifywait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function setboolflag { [ "${2}" = "true" ] && echo "${1}"; }
function setflag { [ "${2}" != "-" ] && printf "%s=%s" "${1}" "${2}"; }

function watch {
inotifywait \
inotifywait --monitor \
"$(setboolflag --csv "${INOTIFY_CFG_CSV}")" \
"$(setboolflag --no-newline "${INOTIFY_CFG_NO_NEWLINE}")" \
"$(setboolflag --quiet "${INOTIFY_CFG_QUIET}")" \
Expand All @@ -42,7 +42,11 @@ function watch {
"$(setflag --timefmt "${INOTIFY_CFG_TIMEFMT}")" \
"$(setflag --timeout "${INOTIFY_CFG_TIMEOUT}")" \
$(join " -e " ${INOTIFY_CFG_EVENTS}) \
"${TARGET}"
"${TARGET}" | \
while read events; do
log "New event detected in '${TARGET}'"
"${SCRIPT}" ${events}
done
}

while true; do
Expand All @@ -54,11 +58,5 @@ while true; do

log "Watching events for '${TARGET}'"

events=$(watch)
if [ $? -ne 0 ]; then
sleep 1
continue
fi

"${SCRIPT}" ${events}
watch
done