]> git.donarmstrong.com Git - debhelper.git/blob - dh_installinit
21526e2bbd6dab3dbb3309eb7ec94f50d502894b
[debhelper.git] / dh_installinit
1 #!/bin/sh -e
2 #
3 # Install debian/init[.d], and set up the postinst and postrm for init
4 # scripts.
5
6 PATH=debian:$PATH:/usr/lib/debhelper
7 . dh_lib
8
9 for PACKAGE in $DH_DOPACKAGES; do
10         TMP=`tmpdir $PACKAGE`
11         init=`pkgfile $PACKAGE init`
12
13         # This is for backwards compatability with debstd, which used either
14         # name.
15         if [ ! "$init" ]; then
16                 init=`pkgfile $PACKAGE init.d`
17         fi
18
19         if [ "$init" ]; then
20                 if [ ! -d $TMP/etc/init.d ]; then
21                         doit "install -d $TMP/etc/init.d"
22                 fi
23
24                 # Figure out what filename to install it as.
25                 if [ "$DH_D_FLAG" ]; then
26                         # -d on the command line sets DH_D_FLAG. We will 
27                         # remove a trailing 'd' from the package name and 
28                         # use that as the name.
29                         script=`expr $PACKAGE : '\(.*\)d$'` || true
30                         if [ ! "$script" ]; then
31                                 echo `basename $0`" warning: \"$PACKAGE\" has no final -d, but -d was specified."
32                                 script=$PACKAGE
33                         fi
34                 elif [ "$DH_INIT_SCRIPT" != "" ]; then
35                         script=$DH_INIT_SCRIPT
36                 else
37                         script=$PACKAGE
38                 fi
39                 doit "install -p -m755 $init $TMP/etc/init.d/$script"
40
41                 # This is set by the -u "foo" command line switch, it's
42                 # the parameters to pass to update-rc.d. If not set, 
43                 # we have to say "defaults".
44                 if [ "$DH_U_PARAMS" = "" ]; then
45                         DH_U_PARAMS="defaults"
46                 fi
47
48                 # -r on the command line sets DH_R_FLAG. If it's set, there
49                 # is no restart on upgrade.
50                 if [ ! "$DH_NOSCRIPTS" ]; then
51                         if [ "$DH_R_FLAG" ]; then
52                                 autoscript "postinst" "postinst-init-norestart" \
53                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
54                                 autoscript "postrm" "postrm-init" \
55                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
56                         else
57                                 autoscript "postinst" "postinst-init" \
58                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
59                                 autoscript "postrm" "postrm-init" \
60                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
61                                 autoscript "prerm" "prerm-init" \
62                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
63                         fi
64                 fi
65         fi
66 done