I have a long-running systemd service, let's call it db.service. It is enabled to start on system boot, but can also be restarted manually.
I also have a oneshot service, les's call it check.service, that performs an integrity check on the database file.
check.service should be run on system boot, and during boot db.service should not start if check.service fails.
But! Here's the caveat: check.service should NOT be run when db.service is restated manually using systemctl restart db.service. And it should be possible to start db.service manually even if check.service fails on boot.
Question
Is there a way to achieve this using systemd services?
Thoughts and observations
I though I could achieve this by using
RequiredBy=db.serviceincheck.service. But that still triggerscheck.servicewhendb.serviceis started.Maybe the problem can be solved in some way by creating a third service,
db-boot.service, that has dependencies on bootdb.serviceandcheck.service. But I haven't been able to figure out how.