-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
31 lines (25 loc) · 813 Bytes
/
entrypoint.sh
File metadata and controls
31 lines (25 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -e
LOG_EXT=${LOG_EXT:-.txt}
EXCLUDE_REGEX=${EXCLUDE_REGEX:-}
TZ=${TZ:-UTC}
export TZ
mkdir -p /logs
echo "📂 Watching all directories inside /watched"
for dir in /watched/*; do
if [ -d "$dir" ]; then
root_dir=$(basename "$dir")
log_file="/logs/${root_dir}${LOG_EXT}"
touch "$log_file"
echo "Watching $dir -> $log_file"
# Start inotifywait in background for each folder
(
inotifywait -m -r ${EXCLUDE_REGEX:+--exclude "$EXCLUDE_REGEX"} "$dir" \
-e create -e delete -e modify -e move --format '%w|%e|%f' |
while IFS='|' read -r filepath event filename; do
echo "$(date +'%Y-%m-%d %H:%M:%S') [$event] ${filepath}${filename}" >> "$log_file"
done
) &
fi
done
wait