"Short version": When a user opens a file on a local share, other users can open only in read-only, until it is closed. I want this to be true for the remote copy of the file: read-only when the local file is opened.
"Details": I have two (to begin) remote file servers (ubuntu) with windows clients (many files and directories) to automatically sync over the internet, in an ssh tunnel (the ADSL connection is pretty bad, and sometimes cut), the file system is ext4. For now I use unison at night, with force newer option and backups to avoid losing data.
I want to get synchronisation (almost) real time by avoiding conflicts, I do not want to resolve conflicts by hand, or as little as possible, because there are multiple users...
I tested unison -repeat watch locally, he forgets changes, so it is not appropriate.
But why not start unison repeatedly by cron, because its performance is fast enough when there are few files change ... My idea: if a file is opened by a user on the LAN A on server A, sends a command (chattr +i ?) that will block the same file on the server B to prevent users from network B to open it (and so to change it)
Unlock the file on server B when it is closed on A by sending a command (chattr -i ?)
And vice versa from B to A
Unlock everything locally by cron (chattr -R -i ?) to 12 h and 19 h for example, a half-day lock is acceptable
Problems: how to run the blockade? must retrieve the name and the file path with inotify... lsyncd? pyinotify? other? (monitoring must be recursive)
What if the connection is out when opening a file?
There exists a "ready-made"? Thank you for any help