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

Re: not starting a daemon upon installation

On Sat, 2020-03-07 at 21:30 +0100, Tomas Pospisek wrote:
> The problem is that installing the package will automatically start
> the
> daemon cluster in a "default" configuration.
> That's a problem for me because etcd differentiates between starting
> the
> cluster for the first time and starting it subsequentially. The first
> time is special as it generates some internal state.
> So I would like to control whether etcd - or for the matter any
> service
> - is started upon package installation.
> I imagine that this would be quite a standard requirement for
> devops/configuration tools aka "please do not run and configure the
> service for me because I want to do it precisely **this way**" (which
> is
> kinda the point of configration automation).
> When I duckduckgo "dpkg do not start service on install" first hit is
> [1] which contains /absurdly involved/ suggestions to achieve "not
> starting a daemon upon installation".
> It /seems/ that the "official" way to achieve "not starting a daemon
> upon installation" is to use `dpkg-divert` to overwrite `policy-rc.d`
> with a script that exits with 101.
> This to me seems again like a awkward, byzantine and brittle way to
> achieve that goal. Also, the only canonical documentation of policy-
> rc.d
> seems to be
> /usr/share/doc/init-system-helpers/README.policy-rc.d.gz, which is
> quite
> cryptic, contains no examples and contains "rc.d" in its name in a
> world
> where systemd is the default, which makes me doubt whether all
> packages
> using systemd will respect policy-rc.d...
> So I'm wondering:
> * is this really the official (twisted ?8-o) way to solve the problem
> of
> not starting a daemon automatically upon installation?
> * why was such an involved method chosen, instead of say setting an
> environment variable DPKG_DONT_START_DAEMON or such?
> [1]
> https://askubuntu.com/questions/74061/install-packages-without-starting-background-processes-and-services#

i can't comment on what might be considered an "official" solution.

fyi, preventing start/stop of _all_ services on package installation is
a requirement of Debian's live-build, which if you're not familiar with
it is a tool to build a Debian live-cd. Building a live environment is
typically done in a chroot and it involves installing many packages
which should not impact the host in terms of starting/stopping

how live-build achieves this is essentially the same as happens to be
discussed in the linked page for Debian's debootstrap package (the tool
for building the base filesystem).

that is to use dpkg-divert to temporarily replace the /sbin/start-stop-
daemon binary with something that essentially just exits with success
(i.e. 0). This could be an empty shell script (or one that prints a
warning about the diversion being in place as in the linked discussion)
or a symlink to /bin/true.

enabling diversion:
dpkg-divert --add --rename /sbin/start-stop-daemon
ln -fs /bin/true /sbin/start-stop-daemon

removing diversion:
rm -f /sbin/start-stop-daemon
dpkg-divert --remove --rename /sbin/start-stop-daemon

someone else has already offered an alternate solution applicable to
individual packages.

if the problem you are experiencing with this particular package you
reference is common, then perhaps a bug should be filed or discussion
take place regarding changing it such that it not try to start its
service upon installation.

Reply to: