5 dh_installinit - install init scripts into package build directories
10 use Debian::Debhelper::Dh_Lib;
14 dh_installinit [debhelper options] [--init-script=scriptname]
15 [-n] [-r] [-d] [-uparams] -- [params]
19 dh_installinit is a debhelper program that is responsible for installing
20 init scripts into package build directories.
22 It also automatically generates the postinst and postrm and prerm commands
23 needed to set up the symlinks in /etc/rc*.d/ and to start and stop the init
26 If a file named debian/package.init exists, then it is installed into
27 etc/init.d/package in the package build directory, with "package" replaced
34 =item B<-n>, B<--noscripts>
36 Do not modify postinst/postrm/prerm scripts.
38 =item B<-r>, B<--no-restart-on-upgrade>
40 Do not restart daemon on upgrade.
42 =item B<-d>, B<--remove-d>
44 Remove trailing "d" from the name of the package, and use the result for the
45 filename the init script is installed as in etc/init.d/ . This may be useful
46 for daemons with names ending in "d". (Note: this takes precedence over
47 the --init-script parameter described below.)
49 =item B<-u>I<params> B<--update-rcd-params=>I<params>
53 Pass "params" to L<update-rc.d(8)>. If not specified, "defaults" will be
54 passed to L<update-rc.d(8)>.
56 =item B<--init-script=>I<scriptname>
58 Use "scriptname" as for the filename the init script is installed as in
59 etc/init.d/ . This is useful if you need to have an init script with a name
60 different from the package's name. Note that if you use this parameter,
61 dh_installinit will look to see if a file in the debian/ directory exists
62 that looks like "scriptname" or "package.scriptname" and if so will install
63 it as the init script in preference to the files it normally installs. This
64 feature is really only useful if you need a single package to install more
71 Note that this command is not idempotent. "dh_clean -k" should be called
72 between invocations of this command. Otherwise, it may cause multiple
73 instances of the same text to be added to maintainer scripts.
79 foreach my $package (@{$dh{DOPACKAGES}}) {
80 my $tmp=tmpdir($package);
82 # Figure out what filename to install it as.
85 # -d on the command line sets D_FLAG. We will
86 # remove a trailing 'd' from the package name and
87 # use that as the name.
89 if ($script=~m/(.*)d$/) {
93 warning("\"$package\" has no final d' in its name, but -d was specified.");
96 elsif ($dh{INIT_SCRIPT}) {
97 $script=$dh{INIT_SCRIPT};
103 my $init=pkgfile($package,$script) || pkgfile($package,"init") ||
104 pkgfile($package,"init.d");
107 if (! -d "$tmp/etc/init.d") {
108 doit("install","-d","$tmp/etc/init.d");
111 doit("install","-p","-m755",$init,"$tmp/etc/init.d/$script");
113 # This is set by the -u "foo" command line switch, it's
114 # the parameters to pass to update-rc.d. If not set,
115 # we have to say "defaults".
117 if (defined($dh{U_PARAMS})) {
118 $params=join(' ',@{$dh{U_PARAMS}});
124 if (! $dh{NOSCRIPTS}) {
125 # -r on the command line sets R_FLAG. If it's set, there
126 # is no restart on upgrade.
128 autoscript($package,"postinst", "postinst-init-norestart",
129 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
130 autoscript($package,"postrm","postrm-init",
131 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
132 autoscript($package,"prerm","prerm-init-norestart",
133 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
136 autoscript($package,"postinst","postinst-init",
137 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
138 autoscript($package,"postrm","postrm-init",
139 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
140 autoscript($package,"prerm","prerm-init",
141 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
151 This program is a part of debhelper.
155 Joey Hess <joeyh@debian.org>