WHAT IT DOES
The directives that only work in pairs.
Fill in the command, the user, and the restart policy, and get a complete unit file with its [Unit], [Service], and [Install] sections. The individual directives are easy to look up; what this writes for you are the ones that have to appear together, and the combinations that start cleanly and then fail an hour later.
Why use it?
Running a program as a service involves more than its command: identity, dependencies, restart policy, and filesystem access need to agree with how it operates.
How to use this tool
- Set the service identity, executable, working directory, and the options your program needs.
- Generate the unit and review its dependencies and hardening restrictions, especially the paths it can write.
- Save the unit and run systemd-analyze verify on the destination test host before installing or enabling it. Generation does not start the service.
Details and limitations
- Waiting for the network writes both After=network-online.target and Wants=network-online.target. After on its own orders the unit behind a target that may never be pulled into the boot, which is why a service that needs the network still starts too early.
- The sandbox option writes NoNewPrivileges, PrivateTmp, ProtectSystem=strict, ProtectHome, and their neighbours, and adds ReadWritePaths for the working directory, because strict makes the whole filesystem read-only and a service that writes anywhere needs that path named back.
- A relative ExecStart is refused rather than written: systemd needs an absolute path, and a unit with a bare command name fails at first start.
- A oneshot service with a restart policy is called out, since it is meant to run and exit and a timer is usually what was wanted.
- A unit with no User= is called out too, because the default is root.
- An empty field writes no directive at all, rather than an empty one, and a user unit installs into default.target instead of multi-user.target.