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
> daemon cluster in a "default" configuration.
> That's a problem for me because etcd differentiates between starting
> 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
> - 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
> kinda the point of configration automation).
> When I duckduckgo "dpkg do not start service on install" first hit is
>  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-
> seems to be
> /usr/share/doc/init-system-helpers/README.policy-rc.d.gz, which is
> cryptic, contains no examples and contains "rc.d" in its name in a
> where systemd is the default, which makes me doubt whether all
> using systemd will respect policy-rc.d...
> So I'm wondering:
> * is this really the official (twisted ?8-o) way to solve the problem
> 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?
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.
dpkg-divert --add --rename /sbin/start-stop-daemon
ln -fs /bin/true /sbin/start-stop-daemon
rm -f /sbin/start-stop-daemon
dpkg-divert --remove --rename /sbin/start-stop-daemon
someone else has already offered an alternate solution applicable to
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.