I have a server with an encrypted filesystem which must be manually brought online after a reboot. Some services require that encrypted filesystem to be mounted in order to read configuration/data files, etc.
Is there a way to tell systemd
that whenever service X starts (even manually), services Y and X should be started automatically?
I know I can script this with a "start all my stuff" script that starts the encrypted filesystem service (which isn't really a service; just a complicated mount command) and then starts everything else I need, but I was wondering if this is something systemd can handle on its own.
So if we name your service X and the other service which should be started automatically (the filesystem) service Y, the following should do the job:
Now if you start service x, service y (the file system) should be started autaomatically. Furthermore if there is an error with service y and it can't start service x won't start either. Sidenote: There are other keywords like "after" or "wants", which are less strict than "Requires". But in your example "Requires" should be the right choice.