Did you ever curse that Debian took so long to shut down, waiting for all the shutdown scripts to complete before the machine was ready to move? Here is a simple recipe to help making sure your package do not slow down the shutdown.
Most of the init.d scripts are simple scripts that during shutdown kill the process they started during boot. But the default halt (0) and reboot (6) shutdown sequences will kill all processes on their own (in the sendsigs script), so there is normally no need for individual packages and init.d scripts to run at shutdown if all they need to do is to kill a daemon. There might be exceptions, for example if the daemons need to stop in a given order, but that do not seem to be the case for most packages. Ubuntu discovered this a while back, and introduced a method to avoid calling stop scripts in runlevel 0 and 6. It is the "multiuser" extension to update-rc.d, and in Ubuntu packages are changed to calls dh_installinit with '-- multiuser' as an argument to enable it. This add the "multiuser" argument (instead of to the "default" argument) to update-rc.d, which go on and set up the boot sequence without references to the script in runlevel 0 and 6. This can be done without such extention, and how is the topic of the rest of my email. To change the runlevel settings of an init.d script using the Debian API, one most first remove it in the postinst, and insert it again. To do this, add code like this in the postinst before the #DEBHELPER# block: if dpkg --compare-versions "$2" lt "0.1"; then update-rc.d -f hotkey-setup remove fi The version number used when comparing should be the version of the package where the change is introduced. Next, change the dh_installinit call in debian/rules file to look like this (note, not the optimal solution): dh_installinit -- start 20 2 3 4 5 . stop 20 1 . This is equivalent to the 'dh_installinit -- multiuser' call on Ubuntu, and will make debhelper add code to call update-rc.d with the given arguments. It is a long-standing Bug in the Debian single user and shutdown sequence that the services are not stopped in the opposite order of the one used when starting them. The default setting is to start at sequence number 20, and stop also using sequence number 20. A better default would have been to use a stop sequence number that is 100 minus the start sequence number, but it is too late to change the behavior of update-rc.d. Each package maintainer can on the other hand fix his package like this: dh_installinit -- start 20 2 3 4 5 . stop 80 1 . Of course, one need to verify that the stop script will still work when stopped at sequence number 80 in the single user runlevel, before introducing such change. And while you work on your init.d scripts, please make sure to update the LSB-style header Should-Stop to reflect that the script do not need to stop in runlevels 0 and 6. See <URL: http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot > for more info on this feature. Happy hacking, -- Petter Reinholdtsen One of the sysvinit maintainers -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]