[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: Prevent apt/dpkg from automatically enabling services during the upgrade process.



On Tue, 3 Oct 2017, cabezachumbo@gmail.com wrote:

Hello!
I guess that the script prevents from enabling currently disabled services.
One more thing, what should I do if I also want that after installing a new
service with "apt install service" it doesn't get enabled automatically in the
installation process?

$ man -k systemd.preset
systemd.preset (5)   - Service enablement presets

$ man systemd.preset
---8<---
| DESCRIPTION
|   Preset files may be used to encode policy which units shall be
|   enabled by default and which ones shall be disabled. They are read
|   by systemctl preset (for more information see systemctl(1)) which
|   uses this information to enable or disable a unit according to
|   preset policy.  systemctl preset is used by the post install
|   scriptlets of RPM packages (or other OS package formats), to
|   enable/disable specific units by default on package installation,
|   enforcing distribution, spin or administrator preset policy. This
|   allows choosing a certain set of units to be enabled/disabled even
|   before installing the actual package.
---8<---
| EXAMPLE
---8<---
|  Example 3. Administrator policy /etc/systemd/system-preset/00-lennart.preset:

|      enable httpd.service
|      enable sshd.service
|      enable postfix.service
|      disable *

|  This enables three specific services and disables all others. This is
|  useful for administrators to specifically select the units to enable,
|  and disable all others. Due to the filename prefix "00-" it will be
|  read early and hence overrides all other preset policy files.
---8<---

The thread is from early October, and presumably the OP has resolved
the issue to their satisfaction. But it was not until today that I
stumbled across the systemd.preset man page, and noticed that it seems
to be saying "Hello, I am the solution to that very problem".

Maybe it will be of interest to somebody.

That is all.

Thank you very much Reco.
Regards.
[Reco wrote:]
It's a hack, but it should work. Create an executable file called
/usr/sbin/policy-rc.d with the following contents:

#!/bin/sh
/bin/systemctl --quiet is-enabled $1 && exit 0
echo All rc operations are disabled by policy: $1 $2
exit 101

Reco


Reply to: