+ordered? By numbers 01-99!
+
+<p>And the numbers are picked using skills, knowledge and negotiation.
+Getting it right is often hard.
+
+<p>The current Debian default is wrong. The stop sequence should by
+default be the reverse of the start sequence. It isn't. The default
+uses '20' for both.
+
+<p>Reordering is hard and sometimes requires cooperation between
+maintainers of all packages involved.
+
+<h2>The ordering problem - an example</h2>
+
+<p>Given two packages with two scripts inserted with the default
+settings in Debian:
+
+<p>Package A: script_a sequence 20 (start and stop)
+<br>Package B: script_b sequence 20 (start and stop)
+
+<p>Along comes script C, which should run before script_a and after
+script_b. Current solution is to change packages A and C or packages
+B and C to get something like this:
+
+<p>Package A: script_a start seq. 22, stop seq. 18
+<br>Package B: script_b sequence 20 (start and stop)
+<br>Package C: script_c start seq 21, stop seq 19
+
+<p>If other scripts depend on the old order of script_a, they will
+have to change their sequence number too. The only way to discover
+this is by a lot of testing, or documenting script dependencies.
+
+<h2>An ordering solution</h2>
+
+<p>Let each script document its dependencies, and generate sequence
+numbers using this dependency information. Example:
+
+<p>Package A: script_a depend on nothing
+<br>Package B: script_b depend on nothing
+<br>Package C: script_c depend on script_b, a dependency of script_a
+
+<p>Generated sequence:
+
+<p>script_b start seq 1, stop seq 3
+<br>script_c start seq 2, stop seq 2
+<br>script_a start seq 3, stop seq 1
+
+<p>An implementation of this system is the dependency based boot
+sequencing, provided by the insserv package. It uses the format
+specified in Linux Software Base to document init.d script
+dependencies.</p>
+
+<h2>Checking the current boot sequence</h2>
+
+Two options are available with the insserv package:
+
+<dl>
+<dt>Static checking of current headers:
+<br><tt>/usr/share/insserv/check-initd-order [-o] [-k]</tt>
+<dd>report mismatch in current ordering.
+
+<dt>Graph of the dependencies:
+<br><a href="sid-base-boot-20080220.dot"><tt>/usr/share/insserv/check-initd-order -g</tt></a>
+<dd>for reviewing dependencies with dotty from graphviz.
+
+</dl>
+
+<h2>Enabling dependency based boot sequencing I</h2>
+
+<p><a href="insserv-enable.png"><img align="right" src="insserv-enable.png" width="50%"></a>
+<ul>
+ <li>Use the insserv package in unstable or testing
+ <li>Low priority debconf question.
+ <li>Only enabled after verfiying that it is safe to enable
+ <li>Converts all start symlinks in rc0.d/ and rc6.d to stop symlinks.
+ <li>Replaces update-rc.d with a wrapper calling insserv
+ <li>Finally reorder symlinks in rc*.d/ using dependencies
+</ul>
+
+<p>Will refuse to enable when obsolete init.d scripts, loops,
+duplicate provides etc is detected</p>
+
+<h2>Enabling dependency based boot sequencing II</h2>
+
+<p><pre>
+# aptitude install insserv
+# dpkg-reconfigure insserv
+info: Checking if it is safe to convert to dependency based boot.
+info: Backing up existing boot scripts in \
+ /var/lib/insserv/bootscripts-20080223T0742.tar.gz
+info: Reordering boot system, log to \
+ /var/lib/insserv/run-20080223T0742.log
+info: Recording new boot sequence in \
+ /var/lib/insserv/bootscripts-20080223T0742-after.list
+info: Use '/usr/sbin/update-bootsystem-insserv \
+ restore' to restore the old boot sequence.
+Adding `diversion of /usr/sbin/update-rc.d to \
+ /usr/sbin/update-rc.d.distrib by insserv'
+success: Boot system successfully converted
+# <a href="sid-base-seqchanges.txt">/var/lib/insserv/insserv-seq-changes \
+ /var/lib/insserv/bootscripts-20080223T0742.tar.gz</a>
+[...]
+#
+</pre>