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

do not enable a service disabled by the user #1849

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

Conversation

OniriCorpe
Copy link
Member

@OniriCorpe OniriCorpe commented May 23, 2024

The problem

if the admin disabled a service using yunohost service disable $app, an upgrade will enable and start it again

Solution

check in the systemd helpers if the service has been deactivated before activating or before starting it up

PR Status

done

How to test

...

helpers/systemd Outdated
Comment on lines 28 to 31
# do not enable a service disabled by the user
if ! yunohost service status $service | grep -q "start_on_boot: disabled"; then
systemctl enable $service --quiet
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I think that part should be entirely removed ... the "start_on_boot" thing is precisely the systemd's enabled/disabled flag, cf https://github.com/YunoHost/yunohost/blob/bookworm/src/service.py#L433

so this code is basically "if the service is enabled, enable it"

Suggested change
# do not enable a service disabled by the user
if ! yunohost service status $service | grep -q "start_on_boot: disabled"; then
systemctl enable $service --quiet
fi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how can we do to not re-enable an intentionally disabled service on update?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just remove the original systemctl enable $service like you already did ? ;P

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hummm yes x)
why is he here in the first place?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we did not really think about the use case of "the user wants the service to be disabled" i think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, but now if a packages uses ynh_add_systemd_config at installation, the service will not be enabled :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue is during upgrade, not install

helpers/systemd Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants