]> git.donarmstrong.com Git - debhelper.git/blob - dh_installinit
r11: Initial revision
[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         EXT=`pkgext $PACKAGE`
12
13         if [ -e debian/${EXT}init ]; then
14                 if [ ! -d $TMP/etc/init.d ]; then
15                         doit "install -d $TMP/etc/init.d"
16                 fi
17
18                 # Figure out what filename to install it as.
19                 if [ "$DH_D_FLAG" ]; then
20                         # -d on the command line sets DH_D_FLAG. We will 
21                         # remove a trailing 'd' from the package name and 
22                         # use that as the name.
23                         script=`expr $PACKAGE : '\(.*\)d$'` || true
24                         if [ ! "$script" ]; then
25                                 echo `basename $0`" warning: \"$PACKAGE\" has no final -d, but -d was specified."
26                                 script=$PACKAGE
27                         fi
28                 else
29                         script=$PACKAGE
30                 fi
31                 doit "install -p -m755 debian/${EXT}init $TMP/etc/init.d/$script"
32
33                 # This is set by the -u "foo" command line switch, it's
34                 # the parameters to pass to update-rc.d. If not set, 
35                 # we have to say "defaults".
36                 if [ "$DH_U_PARAMS" = "" ]; then
37                         DH_U_PARAMS="defaults"
38                 fi
39
40                 # -r on the command line sets DH_R_FLAG. If it's set, there
41                 # is no restart on upgrade.
42                 if [ ! "$DH_NOSCRIPTS" ]; then
43                         if [ "$DH_R_FLAG" ]; then
44                                 autoscript "postinst" "postinst-init-norestart" \
45                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
46                                 autoscript "postrm" "postrm-init" \
47                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
48                         else
49                                 autoscript "postinst" "postinst-init" \
50                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
51                                 autoscript "postrm" "postrm-init" \
52                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
53                                 autoscript "prerm" "prerm-init" \
54                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
55                         fi
56                 fi
57         fi
58 done