path: root/dh_installinit
diff options
authorJoey Hess <>2008-05-08 00:05:30 -0400
committerJoey Hess <>2008-05-08 00:05:30 -0400
commitda8e65c5335e21ba449d03def580bac1355cb0df (patch)
treed423990b8caea86f99e8044a50667d391d4b2cd2 /dh_installinit
parent0dbdf93cb69c3336da3ffac4db50092ca982ff07 (diff)
dh_installinit: Add --restart-after-upgrade, which avoids stopping a daemon in the prerm, and instead restarts it in the postinst, keeping its downtime minimal. Since some daemons could break if files are upgraded while they're running, it's not the default. It might become the default in a future (v8) compatability level. Closes: #471060
Diffstat (limited to 'dh_installinit')
1 files changed, 25 insertions, 6 deletions
diff --git a/dh_installinit b/dh_installinit
index 248d517..7dde363 100755
--- a/dh_installinit
+++ b/dh_installinit
@@ -11,7 +11,7 @@ use Debian::Debhelper::Dh_Lib;
-B<dh_installinit> [S<I<debhelper options>>] [B<--name=>I<name>] [B<-n>] [B<-r>] [B<-d>] [S<B<--> I<params>>]
+B<dh_installinit> [S<I<debhelper options>>] [B<--name=>I<name>] [B<-n>] [B<-R>] [B<-r>] [B<-d>] [S<B<--> I<params>>]
@@ -45,9 +45,20 @@ script or default files. May be useful if the init script is shipped and/or
installed by upstream in a way that doesn't make it easy to let
dh_installinit find it.
+=item B<-R>, B<--restart-after-upgrade>
+Do not stop the init script until after the package upgrade has been
+completed. This is different than the default behavior, which stops the
+script in the prerm, and starts it again in the postinst.
+This can be useful for daemons that should not have a possibly long
+downtime during upgrade. But you should make sure that the daemon will not
+get confused by the package being upgraded while it's running before using
+this option.
=item B<-r>, B<--no-restart-on-upgrade>
-Do not restart init script on upgrade.
+Do not stop init script on upgrade.
=item B<--no-start>
@@ -166,11 +177,19 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
if (! $dh{NOSCRIPTS}) {
if (! $dh{NO_START}) {
- # update-rc.d, and start script
- autoscript($package,"postinst", "postinst-init",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
+ # update-rc.d, and restart (or
+ # start if new install) script
+ autoscript($package,"postinst", "postinst-init-restart",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
+ }
+ else {
+ # update-rc.d, and start script
+ autoscript($package,"postinst", "postinst-init",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
+ }
- if ($dh{R_FLAG}) {
+ if ($dh{R_FLAG} || $dh{RESTART_AFTER_UPGRADE}) {
# stops script only on remove