GisServer/templates/sftp-inotify.sh.j2

13 lines
449 B
Plaintext
Raw Normal View History

2024-06-08 14:39:43 +02:00
#!/bin/bash
inotifywait -m -r -e attrib -e create -e moved_to --format '%w%f' {{ sftp_root }} | while read file
do
current_permissions=$(stat -c %A "$file")
if ! [[ "$current_permissions" =~ ^[^\ ](rw[^\ ]){2}[^\ ]{3}$ ]]; then # long: ^[^\ ]rw[^\ ]rw[^\ ][^\ ][^\ ][^\ ]$ matches "?rw?rw????"
echo "Attribute change detected on $file"
chmod u+rw,g+rw "$file"
else
echo "Skipped change for $file"
fi
done