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