Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
###
### Sudo required
###
sudo: required


###
### Set language
###
language: bash


###
### Install required software
###
before_install:
- sudo apt-get update
- sudo apt-get install -y shellcheck


###
### Run tests
###
script:
- shellcheck --shell=bash watcherd
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# watcherd

[![Build Status](https://travis-ci.org/devilbox/watcherd.svg?branch=master)](https://travis-ci.org/devilbox/watcherd)

watcherd will look for directory changes (added and deleted directories) under the specified path (`-p`) and will execute specified commands or shell scripts (`-a`, `-d`) depending on the event.
Once all events have happened during one round (`-i`), a trigger command can be executed (`-t`).
Note, the trigger command will only be execute when at least one add or delete command has succeeded with exit code 0.
Expand Down Expand Up @@ -34,10 +36,10 @@ Required arguments:
-p <path> Path to directoy to watch for changes.
-a <cmd> Command to execute when a directory was added.
The full path of the new dir will be appended as an argument to
this command.
this command.
-d <cmd> Command to execute when a directory was deletd.
The full path of the new dir will be appended as an argument to
this command.
this command.

Optional arguments:
-t <cmd> Command to execute after all directories have been added or
Expand Down
4 changes: 2 additions & 2 deletions watcherd
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ if [ "${WATCHER}" = "inotify" ]; then
--event delete \
--event move \
--format '%e/\\%w%f' \
"${WATCH_DIR}" | while read output; do
"${WATCH_DIR}" | while read -r output; do
d="${output##*\\}"
if [[ "${output}" =~ ^(CREATE|MOVED_TO),ISDIR/\\ ]]; then
if action "${d}" "${CMD_ADD}" "ADD" "${VERBOSE}"; then
Expand Down Expand Up @@ -334,6 +334,6 @@ else
ALL_DIRS="${NEW_DIRS}"

# Wait before restarting loop
sleep ${INTERVAL}
sleep "${INTERVAL}"
done
fi