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

Detect and prefer system-provided service #1038

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Scrumplex
Copy link
Contributor

Instead of always creating our own service file for the user, detect if
there is a service already present, and skip installing our own
service file.

Some distributions might choose to package the user service as well. For example the AUR packages take the template in the repo, replace the binary path and install it to /usr/lib/systemd/user/espanso.service. To keep the systemd environment of users of those packages clean, we should first check if a service already exists.

@Scrumplex Scrumplex changed the base branch from master to dev March 25, 2022 22:28
@Scrumplex
Copy link
Contributor Author

Rebased on dev instead

@federico-terzi
Copy link
Collaborator

federico-terzi commented Apr 9, 2022

Hey @Scrumplex ,

Thank you for the help! This is super helpful! Please bear with me for delays in the review, I'm going through the busiest period of my life and I only have limited capacity for OS at the moment. I'll get back to you as soon as I can, I hope you'll understand :)

Cheers :)

@federico-terzi
Copy link
Collaborator

Hey!
I've got the chance to review the PR, thank you for the help!
Perhaps I'm missing something, but I don't fully understand the use-case for this additional check. If the service file is installed by the package manager (such as with the AUR package), the start command should be able to pick it up correctly and not require the register command. Just to make sure that I understand, you're suggesting to add this check because a user might:

  • Install Espanso through the AUR
  • Run espanso service register (even though it's not needed there) and misconfigure the service

Did I understand correctly?

Cheers :)

Instead of always creating our own service file for the user, detect if
there is a service already present, and skip installing our own
service file.
Doesn't really matter, as systemd aliases <service-name> to
<service-name>.service anyway. But it's good practice to use the full
unit name.
@Scrumplex
Copy link
Contributor Author

Rebased on dev.

So the problem is the following: On a fresh installation of the AUR package, the service file will be installed for all user environments, but will be disabled by default. Now, if I try to run espanso start, it will tell me that the service is not registered. So the user will just do what espanso says and run espanso service register, which will then place a new systemd unit in the user's folder.
As we already shipped one as part of the package, we only really want to enable the existing unit.
So this PR just adds a check to avoid creating a duplicate systemd unit.

@Scrumplex
Copy link
Contributor Author

By the way: I kinda forgot about this PR 👀

@AucaCoyan
Copy link
Member

Hi! I believe this changes are still relevant to the date
Is it possible to merge this PR?

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

Successfully merging this pull request may close these issues.

None yet

3 participants