aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-06-09 17:46:40 +0100
committerGravatar Joe Banks <[email protected]>2024-06-09 17:46:40 +0100
commit5643045585cbcf6fce0348c9ad4b5d7db0fb6b72 (patch)
tree9ab4f3e151bdf1ebc47ec652ddc3437ac019042f
parentAdd Dockerfile (diff)
Add basic monitoring script
-rwxr-xr-xmonitor.sh20
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;