Canonical method to locally disable an init script?

Bob Proulx bob at proulx.com
Thu Nov 26 01:07:27 GMT 2020


Thorsten Glaser wrote:
> Bob Proulx wrote:
> > Here is an example to help clarify:
> [...]
> > In order for local changes to persist at least one symlink must be
> > present so that the installation tools know that this is previously
> > exist and that they should not install the default.
>
> Ah, thanks, that makes sense.
>
> So using disable is correct, defaults-disabled and remove isn't,
> and the update-rc.d manpage probably could use this piece of
> information,

Almost always the man pages and other documentation for everything
could use more examples cases.  The problem is that the author already
knows how things work and doesn't need the documentation.  The time to
write documentation is when people unfamiliar with the details try to
figure things out.

> and insserv should not warn if all symlinks are K, IIUC?

Warn?  Yes.  See below.  And it is also okay to remove S* links too.
(Such as with "rm /etc/rc?.d/S*foo" for example, leaving the K* links
in place.)  As long as one symlink exists then the state is previously
existing and locally configured and won't be changed.

More clarifying examples.  Building upon my previous.

    root at angst:/etc# find /etc/rc?.d/ -name '*bind9'
    /etc/rc0.d/K04bind9
    /etc/rc1.d/K04bind9
    /etc/rc2.d/K04bind9
    /etc/rc3.d/K04bind9
    /etc/rc4.d/K04bind9
    /etc/rc5.d/K04bind9
    /etc/rc6.d/K04bind9

    root at angst:/etc# apt-get install --reinstall bind9
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
    Need to get 0 B/549 kB of archives.
    After this operation, 0 B of additional disk space will be used.
    Preconfiguring packages ...
    (Reading database ... 242702 files and directories currently installed.)
    Preparing to unpack .../bind9_1%3a9.10.3.dfsg.P4-12.3+deb9u7_amd64.deb ...
    Unpacking bind9 (1:9.10.3.dfsg.P4-12.3+deb9u7) over (1:9.10.3.dfsg.P4-12.3+deb9u7) ...
    Setting up bind9 (1:9.10.3.dfsg.P4-12.3+deb9u7) ...
    insserv: warning: current start runlevel(s) (empty) of script `bind9' overrides LSB defaults (2 3 4 5).
    insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `bind9' overrides LSB defaults (0 1 6).
    Processing triggers for systemd (232-25+deb9u12) ...
    Processing triggers for man-db (2.7.6.1-2) ...

It warned that they were different from the LSB headers in the init
script.  Because they were different.  And that could be any of the
possible differences.  But it did not reset them.

    root at angst:/etc# find /etc/rc?.d -name '*bind9'
    /etc/rc0.d/K04bind9
    /etc/rc1.d/K04bind9
    /etc/rc2.d/K04bind9
    /etc/rc3.d/K04bind9
    /etc/rc4.d/K04bind9
    /etc/rc5.d/K04bind9
    /etc/rc6.d/K04bind9

I customize things and see those warnings so often that they don't
register with me as a warning anymore due to desensitization.  But
let's look at a different case of removing the start links.  I'll
remove them all, reinstall to reset, then customize, reinstall, then
see what remains.

    root at angst:/etc# find /etc/rc?.d -name '*bind9' -delete
    root at angst:/etc# find /etc/rc?.d -name '*bind9'

All removed.  The re-install will reset the links to the defaults.

    root at angst:/etc# apt-get install --reinstall bind9
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
    Need to get 0 B/549 kB of archives.
    After this operation, 0 B of additional disk space will be used.
    [master 386f4e2] saving uncommitted changes in /etc prior to apt run
     Author: rwp <rwp at angst.proulx.com>
     3 files changed, 3 deletions(-)
     delete mode 120000 rc0.d/K04bind9
     delete mode 120000 rc1.d/K04bind9
     delete mode 120000 rc6.d/K04bind9
    Preconfiguring packages ...
    (Reading database ... 242702 files and directories currently installed.)
    Preparing to unpack .../bind9_1%3a9.10.3.dfsg.P4-12.3+deb9u7_amd64.deb ...
    Unpacking bind9 (1:9.10.3.dfsg.P4-12.3+deb9u7) over (1:9.10.3.dfsg.P4-12.3+deb9u7) ...
    Setting up bind9 (1:9.10.3.dfsg.P4-12.3+deb9u7) ...
    Processing triggers for systemd (232-25+deb9u12) ...
    Processing triggers for man-db (2.7.6.1-2) ...
    [master 99bc121] committing changes in /etc after apt run
     Author: rwp <rwp at angst.proulx.com>
     7 files changed, 7 insertions(+)
     create mode 120000 rc0.d/K04bind9
     create mode 120000 rc1.d/K04bind9
     create mode 120000 rc2.d/S03bind9
     create mode 120000 rc3.d/S03bind9
     create mode 120000 rc4.d/S03bind9
     create mode 120000 rc5.d/S03bind9
     create mode 120000 rc6.d/K04bind9

    root at angst:/etc# find /etc/rc?.d -name '*bind9'
    /etc/rc0.d/K04bind9
    /etc/rc1.d/K04bind9
    /etc/rc2.d/S03bind9
    /etc/rc3.d/S03bind9
    /etc/rc4.d/S03bind9
    /etc/rc5.d/S03bind9
    /etc/rc6.d/K04bind9

And things are reset to the default.  Let's remove the S* links.

    root at angst:/etc# rm -f --verbose /etc/rc?.d/S*bind9
    removed '/etc/rc2.d/S03bind9'
    removed '/etc/rc3.d/S03bind9'
    removed '/etc/rc4.d/S03bind9'
    removed '/etc/rc5.d/S03bind9'

    root at angst:/etc# find /etc/rc?.d -name '*bind9'
    /etc/rc0.d/K04bind9
    /etc/rc1.d/K04bind9
    /etc/rc6.d/K04bind9

Removing the S* links instead of disabling them with a K* link.  But
leaving the K* links so it is an installed configuration.  Then
re-install to test the behavior of of things in that configuration.

    root at angst:/etc# apt-get install --reinstall bind9
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
    Need to get 0 B/549 kB of archives.
    After this operation, 0 B of additional disk space will be used.
    [master f23a8c9] saving uncommitted changes in /etc prior to apt run
     Author: rwp <rwp at angst.proulx.com>
     4 files changed, 4 deletions(-)
     delete mode 120000 rc2.d/S03bind9
     delete mode 120000 rc3.d/S03bind9
     delete mode 120000 rc4.d/S03bind9
     delete mode 120000 rc5.d/S03bind9
    Preconfiguring packages ...
    (Reading database ... 242702 files and directories currently installed.)
    Preparing to unpack .../bind9_1%3a9.10.3.dfsg.P4-12.3+deb9u7_amd64.deb ...
    Unpacking bind9 (1:9.10.3.dfsg.P4-12.3+deb9u7) over (1:9.10.3.dfsg.P4-12.3+deb9u7) ...
    Setting up bind9 (1:9.10.3.dfsg.P4-12.3+deb9u7) ...
    insserv: warning: current start runlevel(s) (empty) of script `bind9' overrides LSB defaults (2 3 4 5).
    Processing triggers for systemd (232-25+deb9u12) ...
    Processing triggers for man-db (2.7.6.1-2) ...

In any case though it warns it does not change the locally modified
configuration.

    root at angst:/etc# find /etc/rc?.d -name '*bind9'
    /etc/rc0.d/K04bind9
    /etc/rc1.d/K04bind9
    /etc/rc6.d/K04bind9

Also from the information output it shows I am using etckeeper+git and
and so my output is showing git logging the changes.  I think in this
case it actually enhances things by showing the details of the files
changes as they are happening.

Bob



More information about the Debian-init-diversity mailing list