source: main/trunk/greenstone2/runtime-src/packages/apache-httpd/install-bindist.sh@ 21906

Last change on this file since 21906 was 21906, checked in by ak19, 14 years ago

Reinstating some of the handling of envvars file to before previous

  • Property svn:executable set to *
File size: 5.5 KB
RevLine 
[18814]1#!/bin/sh
2#
3# Licensed to the Apache Software Foundation (ASF) under one or more
4# contributor license agreements. See the NOTICE file distributed with
5# this work for additional information regarding copyright ownership.
6# The ASF licenses this file to You under the Apache License, Version 2.0
7# (the "License"); you may not use this file except in compliance with
8# the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18#
19# Usage: install-bindist.sh [ServerRoot]
20# This script installs the Apache binary distribution and
21# was automatically created by binbuild.sh.
22
23
24##
25## determine path to (optional) Perl interpreter
26##
27PERL=no-perl5-on-this-system
28perls='perl5 perl'
29path=`echo $PATH | sed -e 's/:/ /g'`
30found_perl=0
31
32for dir in ${path} ; do
33 for pperl in ${perls} ; do
34 if test -f "${dir}/${pperl}" ; then
35 if `${dir}/${pperl} -v >/dev/null 2>&1` ; then
36 PERL="${dir}/${pperl}"
37 found_perl=1
38 break
39 fi
40 fi
41 done
42 if test $found_perl = 1 ; then
43 break
44 fi
45done
46
[18878]47if [ "x$1" = "x" ]
[18814]48then
49 echo "Number of arguments should be 1. Provide the root directory for the web server."
50 exit 1
51else
[18878]52 SR="$1"
[18814]53fi
54
[21895]55# we're the ones putting the apache httpd together, including the envvars file
56# so we can over-write it
[21906]57if [ -f "$SR/bin/envvars" ]
58then
59 echo "[Preserving existing envvars settings.]"
60 HAD_ENVVARS=yes
61else
62 HAD_ENVVARS=no
63fi
[18814]64
[18827]65# Need to run this script from its own directory
66# instead of whatever directory it may be called from
[18878]67#currentdir=$(cd `dirname "$0"` && pwd)
68currentdir="`dirname \"$0\"`"
69currentdir="`cd \"$currentdir\" && pwd`"
70cd "$currentdir"
[18827]71
[18878]72sed -e "s%\*\*APACHE_HOME_OS\*\*%$SR%" "$SR/conf/httpd.conf.in" > "$SR/conf/httpd.conf"
[18814]73
[21894]74sed -e "s;^#!\@perlbin\@.*;#!$PERL;" -e "s;\@exp_installbuilddir\@;$SR/build;" \
[18878]75 apxs.in > "$SR/bin/apxs"
[18814]76
[18827]77# usually we're updating existing files, so need to copy them over into tmp files first
[19036]78#PRE=`grep "^prefix = " build/config_vars.mk`
79#PRE=`echo $PRE | sed -e "s;prefix = ;;"`
[21894]80sed -e "s%\*\*APACHE_HOME_OS\*\*%$SR%" build/config_vars.mk > "$SR/build/config_vars.mk.tmp"
[18878]81mv "$SR/build/config_vars.mk.tmp" "$SR/build/config_vars.mk"
82chmod u+rwx "$SR/build/config_vars.mk"
[18814]83
[18878]84sed -e "s;^#!/.*;#!$PERL;" bin/dbmmanage > "$SR/bin/dbmmanage.tmp"
85mv "$SR/bin/dbmmanage.tmp" "$SR/bin/dbmmanage"
[18814]86
[21894]87# IMPORTANT: need to insert the ServerRoot nested inside quotes into the apachectl file
[18879]88sed -e "s%\*\*APACHE_HOME_OS\*\*%\"$SR\"%" \
89 -e "s%^HTTPD=.*$%HTTPD=\"$SR/bin/httpd\"%" \
90 -e "s%\$HTTPD%\"\$HTTPD\" -d \"$SR\"%" bin/apachectl > "$SR/bin/apachectl.tmp"
[18878]91mv "$SR/bin/apachectl.tmp" "$SR/bin/apachectl"
92chmod u+rwx "$SR/bin/apachectl"
[18814]93
[21894]94sed -e "s%\*\*APACHE_HOME_OS\*\*%$SR%" \
[18878]95 bin/envvars-std > "$SR/bin/envvars-std.tmp"
96mv "$SR/bin/envvars-std.tmp" "$SR/bin/envvars-std"
97chmod u+rwx "$SR/bin/envvars-std"
[18814]98
[21906]99if [ $HAD_ENVVARS = no ]
100then
101 cp -p "$SR/bin/envvars-std" "$SR/bin/envvars"
102fi
103# Either way, do a find and replace on APACHE_HOME_OS in the envvars file
[21895]104sed -e "s%\*\*APACHE_HOME_OS\*\*%$SR%" "$SR/bin/envvars" > "$SR/bin/envvars.tmp"
105mv "$SR/bin/envvars.tmp" > "$SR/bin/envvars"
106
107
[19016]108# Non-crucial files (replacements not essential)
109# but replacing the occurrences of $PRE in them with $SR anyway:
[19036]110REPLACELIST="conf/extra/httpd-dav.conf conf/extra/httpd-manual.conf conf/extra/httpd-autoindex.conf conf/extra/httpd-vhosts.conf conf/extra/httpd-ssl.conf conf/extra/httpd-multilang-errordoc.conf conf/original/extra/httpd-dav.conf conf/original/extra/httpd-manual.conf conf/original/extra/httpd-autoindex.conf conf/original/extra/httpd-vhosts.conf conf/original/extra/httpd-ssl.conf conf/original/extra/httpd-multilang-errordoc.conf conf/original/httpd.conf lib/apr-util-1/apr_dbd_odbc.la lib/apr-util-1/apr_dbd_sqlite3.la lib/pkgconfig/apr-util-1.pc lib/pkgconfig/apr-1.pc lib/libaprutil-1.la lib/libapr-1.la build/config_vars.mk build/config.nice build/apr_rules.mk bin/apu-1-config bin/apr-1-config include/ap_config_auto.h include/ap_config_layout.h"
[19016]111
[19036]112for one_file in $REPLACELIST; do
[19787]113 if [ -f $one_file ]; then
114 sed -e "s%\*\*APACHE_HOME_OS\*\*%$SR%" "$one_file" > "$one_file.tmp"
115 mv $one_file.tmp $one_file
116 chmod u+w $one_file
117 fi
[19016]118done
119
[18814]120echo "Ready."
121echo " +--------------------------------------------------------+"
122echo " | You now have successfully installed the Apache |"
123echo " | HTTP server. To verify that Apache actually works |"
124echo " | correctly you should first check the (initially |"
125echo " | created or preserved) configuration files: |"
126echo " | |"
127echo " | $SR/conf/httpd.conf"
128echo " | |"
129echo " | You should then be able to immediately fire up |"
130echo " | Apache the first time by running: |"
131echo " | |"
132echo " | $SR/bin/apachectl start "
133echo " | |"
134echo " | Thanks for using Apache. The Apache Group |"
135echo " | http://www.apache.org/ |"
136echo " +--------------------------------------------------------+"
137echo " "
Note: See TracBrowser for help on using the repository browser.