Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement suggestion for systemd units: Provide user units alongside the system units #459

Open
raek opened this issue Sep 24, 2024 · 2 comments

Comments

@raek
Copy link

raek commented Sep 24, 2024

The systemd units provided by pat are installed on the system level (and require sudo for administration). Have you considered using "user units" instead? Systemd runs a system service manager as root, but it also runs a user service manager for each active user (more on that below). For inspiration, Syncthing provide both system and user units (presumably for convenience).

The system and user unit files would be almost identical. The only difference is that:

  • the user unit does not need any template parameter
  • the user unit does not need the User=%i line
  • WantedBy=default.target is used instead of multi-user.target
  • You used sudo systemctl ... for system units and systemctl --user ... for user units (no sudo)
  • The unit file is stored in /usr/lib/systemd/user/pat.service instead of /lib/systemd/system/[email protected]

If you have Syncthing installed, you can take a look yourself using systemctl cat syncthing@ and systemctl --user cat syncthing.

One caveat is that the default behavior of systemd is to shut down the user service manager (and all its services) when the user logs out. It is also not started when the computer boots. This can be changed with configuration, however. Just run this command once:

sudo loginctl enable-linger $USER

When "linger" is active for the user, its service manager is tarted on boot and will remain running even if the user is logged out. This is great for servers.

What do you think? I can make the code changes and a pull request if thou think this is a good idea.

@raek raek changed the title systemd: Procide user units alongside the system units Improvement suggestion for systemd units: Provide user units alongside the system units Sep 24, 2024
@raek
Copy link
Author

raek commented Sep 24, 2024

Hmm. I don't know how this would interplay with the ax25 service (which I assume has to run as root?). I'm not aware of any way of making the pat.service user unit depend on the ax25.service system unit (since they run in different service managers / "systemd instances").

This might have been a half-baked idea.

@raek
Copy link
Author

raek commented Sep 24, 2024

I made a work in progress commit here: raek@70005bb

I've tested it with "telnet", which is the only "modem" I have working as of now. (I started using pat and Winlink yesterday...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants