This is probably better being a 3rd-party thing. I’m planning to write something like this; does anything like it exist already?
The main point is to sync applications, normally single-user. Problem being, that partial syncs and 2 devices running/starting the same program at once can result in a bad state.
Locking looks like this:
- Instead of execing the executable, the locking middleware is executed.
- It checks, if¹:
- A specific folder is up to date
- Other device(s) are alive
- If the device shows up as disconnected in ST, fail? Try to SSH in to the device(s)? Check last seen date? Ask the user, if the other computer is fenced (so, not up without network) or at least the process is not running.
- There are any locks (restic-style: timestamped expiry)
- SSH in to the device(s) to confirm once again, that the process in question is not running.
- Create a lock, switch folder to send-only
- Remove the lock, switch to receive-only, or send-receive, depending on the folder.
Locking and confirmations done with a basic requests server instead?
Conflict resolution? Abort on conflicts? Make a restic backup before switching out of send-only?
¹ Not quite sure on how to perform the checking here. In theory, I have an always-online node as well. (For better or worse, can’t use Nextcloud for some of the processes.) Fail if not connected to the always-online node? Must be connected or last seen above d?