]> granicus.if.org Git - apache/blob - build/install-bindist.sh.in
Fix the binary build install script so that the build logic
[apache] / build / install-bindist.sh.in
1 #!/bin/sh
2 #
3 # Usage: install-bindist.sh [ServerRoot]
4 # This script installs the Apache binary distribution and
5 # was automatically created by binbuild.sh.
6  
7 lmkdir()
8 {
9   path=""
10   dirs=`echo $1 | sed -e 's%/% %g'`
11   mode=$2
12  
13   set -- ${dirs}
14  
15   for d in ${dirs}
16   do
17     path="${path}/$d"
18     if test ! -d "${path}" ; then
19       mkdir ${path}
20       if test $? -ne 0 ; then
21         echo "Failed to create directory: ${path}"
22         exit 1
23       fi
24       chmod ${mode} ${path}
25     fi
26   done
27 }
28  
29 lcopy()
30 {
31   from=$1
32   to=$2
33   dmode=$3
34   fmode=$4
35  
36   test -d ${to} || lmkdir ${to} ${dmode}
37   (cd ${from} && tar -cf - *) | (cd ${to} && tar -xf -)
38  
39   if test "X${fmode}" != X ; then
40     find ${to} -type f -print | xargs chmod ${fmode}
41   fi
42   if test "X${dmode}" != X ; then
43     find ${to} -type d -print | xargs chmod ${dmode}
44   fi
45 }
46  
47 ##
48 ##  determine path to (optional) Perl interpreter
49 ##
50 PERL=no-perl5-on-this-system
51 perls='perl5 perl'
52 path=`echo $PATH | sed -e 's/:/ /g'`
53  
54 for dir in ${path} ;  do
55   for pperl in ${perls} ; do
56     if test -f "${dir}/${pperl}" ; then
57       if `${dir}/${pperl} -v | grep 'version 5\.' >/dev/null 2>&1` ; then
58         PERL="${dir}/${pperl}"
59         break
60       fi
61     fi
62   done
63 done
64  
65 if [ .$1 = . ]
66 then
67   SR=@default_dir@
68 else
69   SR=$1
70 fi
71 echo "Installing binary distribution for platform @os@"
72 echo "into directory $SR ..."
73 lmkdir $SR 755
74 lmkdir $SR/proxy 750
75 lmkdir $SR/logs 755
76 lmkdir $SR/build 755
77 lcopy bindist/build $SR/build 750 750
78 lcopy bindist/man $SR/man 755 644
79 if [ -d bindist/modules ]
80 then
81   lcopy bindist/modules $SR/modules 750 750
82 fi
83 lcopy bindist/include $SR/include 755 644
84 lcopy bindist/icons $SR/icons 755 644
85 lcopy bindist/manual $SR/manual 755 644
86 lcopy bindist/cgi-bin $SR/cgi-bin 750 750
87 if [ -f $SR/bin/envvars ]
88 then
89   echo "[Preserving existing envvars settings.]"
90   cp -p $SR/bin/envvars ./envvars.orig
91   HAD_ENVVARS=yes
92 else
93   HAD_ENVVARS=no
94 fi
95 lcopy bindist/bin $SR/bin 750 750
96 if [ $HAD_ENVVARS = yes ]
97 then
98   cp -p ./envvars.orig $SR/bin/envvars
99   rm ./envvars.orig
100 fi
101 lcopy bindist/lib $SR/lib 750 750
102 if [ -d $SR/conf ]
103 then
104   echo "[Preserving existing configuration files.]"
105   cp bindist/conf/*-std.conf $SR/conf/
106 else
107   lcopy bindist/conf $SR/conf 750 640
108   sed -e "s%@default_dir@%$SR%" $SR/conf/httpd-std.conf > $SR/conf/httpd.conf
109 fi
110 if [ -d $SR/htdocs ]
111 then
112   echo "[Preserving existing htdocs directory.]"
113 else
114   lcopy bindist/htdocs $SR/htdocs 755 644
115 fi
116 if [ -d $SR/error ]
117 then
118   echo "[Preserving existing error documents directory.]"
119 else
120   lcopy bindist/error $SR/error 755 644
121 fi
122  
123 sed -e "s;^#!\@perlbin\@.*;#!$PERL;" -e "s;\@prefix\@;$SR;" \
124         support/apxs.in > $SR/bin/apxs
125 PRE=`grep "^prefix = " bindist/build/config_vars.mk`
126 PRE=`echo $PRE | sed -e "s;prefix = ;;"`
127 sed -e "s;$PRE;$SR;" bindist/build/config_vars.mk > $SR/build/config_vars.mk
128 sed -e "s;^#!/.*;#!$PERL;" bindist/bin/dbmmanage > $SR/bin/dbmmanage
129 sed -e "s%@default_dir@%$SR%" \
130         -e "s%^HTTPD=.*$%HTTPD=\"$SR/bin/httpd -d $SR\"%" bindist/bin/apachectl > $SR/bin/apachectl
131 sed -e "s%@default_dir@%$SR%" \
132         bindist/bin/envvars-std > $SR/bin/envvars-std
133 if [ $HAD_ENVVARS = no ]
134 then
135     cp -p $SR/bin/envvars-std $SR/bin/envvars
136 fi
137  
138 echo "Ready."
139 echo " +--------------------------------------------------------+"
140 echo " | You now have successfully installed the Apache @ver@  |"
141 echo " | HTTP server. To verify that Apache actually works      |"
142 echo " | correctly you should first check the (initially        |"
143 echo " | created or preserved) configuration files:             |"
144 echo " |                                                        |"
145 echo " |   $SR/conf/httpd.conf"
146 echo " |                                                        |"
147 echo " | You should then be able to immediately fire up         |"
148 echo " | Apache the first time by running:                      |"
149 echo " |                                                        |"
150 echo " |   $SR/bin/apachectl start "
151 echo " |                                                        |"
152 echo " | Thanks for using Apache.       The Apache Group        |"
153 echo " |                                http://www.apache.org/  |"
154 echo " +--------------------------------------------------------+"
155 echo " "