3 # Install debian/init[.d], and set up the postinst and postrm for init
6 BEGIN { push @INC, "debian", "/usr/share/debhelper" }
10 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
11 $TMP=tmpdir($PACKAGE);
13 # Figure out what filename to install it as.
16 # -d on the command line sets D_FLAG. We will
17 # remove a trailing 'd' from the package name and
18 # use that as the name.
20 if ($script=~m/(.*)d$/) {
24 warning("\"$PACKAGE\" has no final d' in its name, but -d was specified.");
27 elsif ($dh{INIT_SCRIPT}) {
28 $script=$dh{INIT_SCRIPT};
34 $init=pkgfile($PACKAGE,$script) || pkgfile($PACKAGE,"init") ||
35 pkgfile($PACKAGE,"init.d");
38 if (! -d "$TMP/etc/init.d") {
39 doit("install","-d","$TMP/etc/init.d");
42 doit("install","-p","-m755",$init,"$TMP/etc/init.d/$script");
44 # This is set by the -u "foo" command line switch, it's
45 # the parameters to pass to update-rc.d. If not set,
46 # we have to say "defaults".
48 if (defined($dh{U_PARAMS})) {
49 $params=join(' ',@{$dh{U_PARAMS}});
55 if (! $dh{NOSCRIPTS}) {
56 # -r on the command line sets R_FLAG. If it's set, there
57 # is no restart on upgrade.
59 autoscript($PACKAGE,"postinst","postinst-init-norestart",
60 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
61 autoscript($PACKAGE,"postrm","postrm-init",
62 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
65 autoscript($PACKAGE,"postinst","postinst-init",
66 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
67 autoscript($PACKAGE,"postrm","postrm-init",
68 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
69 autoscript($PACKAGE,"prerm","prerm-init",
70 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");