Canonical method to locally disable an init script?

Bob Proulx bob at proulx.com
Tue Nov 24 07:08:56 GMT 2020


Thorsten Glaser wrote:
> 	sudo /usr/sbin/update-rc.d -f rng-tools-debian remove
...
> However, each update of the package re-enables it, as etckeeper shows:

    man update-rc.d  (ignoring the man page formatting errors that
    are apparently there)

       A common system administration error is to delete the links with the
       thought that this will "disable" the service, i.e., that this will
       prevent the service from being started.  However, if all links have
       been deleted then the next time the package is upgraded, the package's
       postinst script will run update-rc.d again and this will reinstall
       links at their factory default locations.  The correct way to disable
       services is to configure the service as stopped in all runlevels in
       which it is started by default.  In the System V init system this means
       renaming the service's symbolic links from S to K.  .P The script .BI
       /etc/init.d/ name must exist before update-rc.d is run to create the
       links.

Here is an example to help clarify:

    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

    root at angst:/etc# update-rc.d bind9 disable

    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

If all links are removed then there is no way for update-rc.d/insserv
to know that it isn't doing a pristine fresh installation.  And
therefore the links are "installed for the first time" as far as they
know.

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.

Hope that helps!
Bob



More information about the Debian-init-diversity mailing list