diff options
Diffstat (limited to 'monitor.sh')
-rwxr-xr-x | monitor.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/monitor.sh b/monitor.sh new file mode 100755 index 0000000..6bf4236 --- /dev/null +++ b/monitor.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +if [ -z ${HOOK_SCRIPT+x} ]; then + echo "Missing HOOK_SCRIPT environment variable, set it to the script to run upon file changes"; + exit 1; +else + if ! test -f $HOOK_SCRIPT; then + echo "The file pointed to by HOOK_SCRIPT does not exist, check your container mounts."; + exit 1; + fi; + + if ! test -x $HOOK_SCRIPT; then + echo "HOOK_SCRIPT is not an executable file (missing +x bit), check file permissions of the hook script." + exit 1; + fi; +fi + +while inotifywait -r /opt/monitor; do + $HOOK_SCRIPT +done; |