5

This question already has an answer here:

On Debian, if the package you're installing has systemd services, they will be automatically enabled and started at post-install. I have found a way to disable the latter, but not the former (yet).

It seems like the post-install scripts use deb-systemd-helper to do this, which means disabling it shouldn't be impossible.

Edit: This is what I ended up doing.

/etc/systemd/system-preset/00-disable-all.preset:

disable *

marked as duplicate by Stephen Kitt debian Nov 25 '18 at 22:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I believe presets would be the way to go here... – Jeff Schaller Nov 25 '18 at 22:02
  • How can I use presets to prevent all package installations from enabling their services though? – Hwi417 Nov 25 '18 at 22:18
  • 1
    Look through the duplicate question's answer regarding presets and to the systemd doc which shows how to default-deny services. – Jeff Schaller Nov 25 '18 at 22:33
3

It looks like "you can just create a symlink to mask ssh.service, before installing the package". E.g. ln -s /dev/null /etc/systemd/system/ssh.service.

I suppose this requires that you know the name of all services created by the package.

I am aware of one minor disadvantage for this approach. If you have a masked service which is also marked as "enabled", then systemd will log a warning during startup.

Note that a systemd "mask" will prevent the service from being started by any method, including manually running systemctl start ssh. So depending on what you want to do, you might want to remove the mask after you've installed the package.


If the package is ssh, it has a specific hack you can use instead! Bad news: this implies that a specific hack is needed in the package because all the other approaches have disadvantages. But you can have a look at the approaches I considered if you like :-). Configuring my sshd securely (with automation)

  • 2
    I'm looking for a way that works for every package that does this, and the masking one is one of the solutions that I'd like to avoid. – Hwi417 Nov 25 '18 at 21:37
  • @Hwi417 I think you might have to resort to a dpkg-divert hack. I really want a feature similar to this, but I couldn't find it either. – sourcejedi Nov 25 '18 at 21:42
  • There is always the possibility of avoiding systemd altogether ;) – Rui F Ribeiro Nov 25 '18 at 22:02
  • @RuiFRibeiro and doing what, exactly? I think so far I've assumed systemd for simplicity, but I don't see how avoiding it helps. – sourcejedi Nov 26 '18 at 8:55
  • 1
    @sourcejedi It just hit me now you want to prevent enabling and not starting. hmmmm Dummy me. – Rui F Ribeiro Nov 26 '18 at 10:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.