I have a series of mutually exclusive systemd services that are started and stopped by users as needed. Each of the services requires exclusive use of some hardware, so many of the services conflict with each other. (But not all services conflict with all other services)
To manage this I've used Conflicts=, which almost works perfectly, however the ExecStart of the starting service seems to run while the ExecStop script of the conflicting service is still running running, which causes the starting service to fail as the hardware resources are not yet available.
If I have the start scripts sleep for some safe amount of time, like 30 seconds, they function perfectly, but I'd much rather them start as soon as the conflicting service stops.
After= doesn't seem to work as the services can be stopped and started repeatedly, in arbitrary order, and After= causes a cyclical dependency.
Is there a way to do this in systemd without resorting to checking if a conflict is running inside the ExecStart scripts?