1 #!/bin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 #ident "@(#)install-apache 1.21 09/05/25 SMI" 27 28 . ${SRC}/tools/install.subr 29 30 # functions - search for "START HERE" to find start of control flow 31 32 ins_file() { 33 iprog=$1 34 idir=$2 35 imode=$3 36 _install N ${iprog} ${idir}/${iprog} ${imode} 37 } 38 39 install_jserv() { 40 cd ${TOP}/${JSERV_VERSION}/src/c 41 ins_file jserv_shmedit ${BINDIR} 555 42 ins_file mod_jserv.so ${LIBEXECDIR} 555 43 44 cd ../java 45 ins_file ApacheJServ.jar ${LIBEXECDIR} 555 46 47 cd ../.. 48 find docs -depth -print | cpio -pdum ${JSERVDIR} 49 rm -f ${JSERVDIR}/docs/Makefile* 50 rm -f ${JSERVDIR}/docs/STATUS.txt 51 rm -f ${JSERVDIR}/docs/api/Makefile* 52 53 cd example 54 ins_file Hello.class ${VARDIR}/servlets 644 55 ins_file IsItWorking.class ${VARDIR}/servlets 644 56 57 cd ../conf 58 ins_file jserv.conf ${CONFDIR} 555 59 ins_file jserv.properties ${CONFDIR} 555 60 ins_file zone.properties ${CONFDIR} 555 61 } 62 63 disable_suexec() { 64 cd ${BINDIR} 65 rm -f suexec.disabled 66 mv suexec suexec.disabled 67 } 68 69 install_logs() { 70 mkdir -p ${VARDIR}/logs 71 for i in access_log error_log suexec_log mod_jserv.log 72 do 73 rm -f ${VARDIR}/logs/$i 74 touch ${VARDIR}/logs/$i 75 done 76 } 77 78 install_proxydir() { 79 mkdir -p ${VARDIR}/proxy 80 } 81 82 # apache installs the manual in the document root, but we 83 # really want it in /usr/apache instead of /var/apache 84 # 85 move_htdocs() { 86 cd ${VARHTDOCS} 87 if [ -d manual ]; then 88 find manual -depth -print | cpio -pdum ${USRHTDOCS} 89 rm -rf manual 90 fi 91 } 92 93 install_startup_files() { 94 cd ${TOP}/Solaris 95 _install N apache.sh ${ROOT}/etc/init.d/apache 744 96 _install H ${ROOT}/etc/init.d/apache ${ROOT}/etc/rc3.d/S50apache 97 _install H ${ROOT}/etc/init.d/apache ${ROOT}/etc/rc2.d/K16apache 98 _install H ${ROOT}/etc/init.d/apache ${ROOT}/etc/rc1.d/K16apache 99 _install H ${ROOT}/etc/init.d/apache ${ROOT}/etc/rc0.d/K16apache 100 _install H ${ROOT}/etc/init.d/apache ${ROOT}/etc/rcS.d/K16apache 101 } 102 103 install_readme() { 104 cd ${TOP}/Solaris 105 ins_file README.Solaris ${CONFDIR} 444 106 } 107 108 install_tomcatcon() { 109 cd ${TOP}/${TOMCATCON_VERSION}/native/apache-1.3 110 ins_file mod_jk.so ${LIBEXECDIR} 555 root bin 111 112 cd ${TOP}/Solaris 113 ins_file jk.conf ${CONFDIR} 555 114 ins_file workers.properties ${CONFDIR} 555 115 } 116 117 install_auth_gss() { 118 cd ${TOP}/mod_auth_gss 119 ins_file mod_auth_gss.so ${LIBEXECDIR} 555 120 } 121 122 fix_config_files() { 123 cd ${CONFDIR} 124 rm -f *.default 125 sed -f ${TOP}/Solaris/httpdconf.sed httpd.conf > httpd.conf-example 126 rm -f httpd.conf 127 } 128 129 # remove stuff from the proto dir that apache installs and that 130 # we don't want to ship 131 132 cleanup_proto() { 133 rm -rf ${ROOT}/var/run/apache 134 } 135 136 post_process() { 137 cd ${BINDIR} 138 for i in ab htdigest htpasswd httpd jserv_shmedit logresolve \ 139 rotatelogs suexec.disabled 140 do 141 chmod u+w ${i} 142 ${SRC}/tools/post_process ${i} 143 chmod u-w ${i} 144 done 145 146 cd ${LIBEXECDIR} 147 for i in *.so 148 do 149 chmod u+w ${i} 150 ${SRC}/tools/post_process_so ${i} 151 chmod u-w ${i} 152 done 153 } 154 155 fix_apache_perms() { 156 chmod 744 ${ROOT}/etc/init.d/apache 157 158 cd ${CONFDIR} 159 find . -type d -exec chmod 755 {} \; 160 find . -type f -exec chmod 644 {} \; 161 162 # special fixups for mod_ssl config dirs/files 163 164 chmod 700 ssl.key 165 166 # for distribution packages, we don't ship server 167 # certs or keys, but for testing, you can comment 168 # the following lines, and the dummy certificate 169 # we generate during the build will be left in place. 170 171 cd ssl.crt 172 rm -f *.[01] .[01] 173 rm -f *.crt 174 cd ../ssl.csr 175 rm -f *.csr 176 cd ../ssl.key 177 rm -f *.key 178 cd ../ssl.prm 179 rm -f *.prm 180 181 # end of mod_ssl fixups 182 183 cd ${PREFIX} 184 APDIRS="bin htdocs include jserv libexec man perl5" 185 find ${APDIRS} -type d -exec chmod 755 {} \; 186 find ${APDIRS} -type f -exec chmod 555 {} \; 187 188 cd ${BINDIR} 189 chmod 700 suexec.disabled 190 191 cd ${MANDIR} 192 find . -type f -exec chmod 444 {} \; 193 194 cd ${INCLUDEDIR} 195 find . -type f -exec chmod 644 {} \; 196 197 cd ${VARDIR} 198 APDIRS="cgi-bin htdocs icons logs proxy servlets" 199 find ${APDIRS} -type d -exec chmod 755 {} \; 200 find ${APDIRS} -type f -exec chmod 644 {} \; 201 202 cd ${VARDIR}/cgi-bin 203 chmod 555 * 204 205 chmod 755 ${VARDIR}/proxy 206 207 chmod 755 ${VARDIR}/logs 208 209 cd ${VARDIR}/logs 210 chmod 644 * 211 } 212 213 fix_jserv_perms() { 214 cd ${JSERVDIR} 215 find . -type d -exec chmod 755 {} \; 216 find . -type f -exec chmod 644 {} \; 217 } 218 219 fix_apachectl() { 220 cd ${BINDIR} 221 rm -f apachectl.out 222 sed -e 's/GOOP/HTTPD/g' apachectl > apachectl.out 223 rm -f apachectl 224 mv apachectl.out apachectl 225 chmod 555 apachectl 226 } 227 228 fix_apxs() { 229 cd ${BINDIR} 230 rm -f apxs.out 231 sed -e '/^my $CFG_CC/c\ 232 my $CFG_CC = q(cc);' apxs > apxs.out 233 rm -f apxs 234 mv apxs.out apxs 235 chmod 555 apxs 236 } 237 238 # START HERE - actual script processing starts here 239 240 # Even though this is called "install-apache", it doesn't really 241 # install the whole thing. The perl side of mod_perl is installed 242 # by make all, we just need to fix permissions. Much of apache 243 # itself is installed by make install - again, we need to fix 244 # permissions. What we install here are modules that apache 245 # won't install as part of its normal build. Each install task 246 # is a function, so it's relatively easy to add new stuff. 247 248 APACHE_VERSION=`grep "^SERVER=" Makefile.sfw | sed s/SERVER=//` 249 JSERV_VERSION=ApacheJServ-1.1.2 250 MOD_PERL_VERSION=mod_perl-1.31 251 TOMCATCON_VERSION=tomcat-connectors-1.2.27-src 252 253 # install locations 254 255 PREFIX=${ROOT}/usr/apache 256 CONFDIR=${ROOT}/etc/apache 257 VARDIR=${ROOT}/var/apache 258 DEFDIR=${ROOT}/etc/default 259 BINDIR=${PREFIX}/bin 260 USRHTDOCS=${PREFIX}/htdocs 261 INCLUDEDIR=${PREFIX}/include 262 LIBEXECDIR=${PREFIX}/libexec 263 JSERVDIR=${PREFIX}/jserv 264 MANDIR=${PREFIX}/man 265 MAN1DIR=${PREFIX}/man/man1 266 MAN3DIR=${PREFIX}/man/man3 267 MAN8DIR=${PREFIX}/man/man8 268 PERLDIR=${PREFIX}/perl5 269 270 VARHTDOCS=${VARDIR}/htdocs 271 272 TOP=`pwd` 273 274 install_jserv 275 disable_suexec 276 install_logs 277 install_proxydir 278 install_readme 279 install_tomcatcon 280 install_auth_gss 281 move_htdocs 282 install_startup_files 283 cleanup_proto 284 fix_config_files 285 post_process 286 287 # all installation should be done before this point, so the functions 288 # that fixup permissions can get everything that is installed. 289 290 fix_apache_perms 291 fix_jserv_perms 292 293 # also need to make one last fix to apachectl after it's installed. 294 # can't patch it prior to install, because apache install runs sed 295 # on it and messes up our change. Also, apxs winds up with the 296 # path to cc that we use to compile, so we need to fix that to 297 # be generic. 298 299 fix_apachectl 300 fix_apxs 301 302 for pmfile in ${PERLDIR}/5.8.4/*/Apache/Resource.pm 303 do 304 if [ -f ${pmfile} ]; then 305 _fixup_perl ${pmfile} 306 chmod 555 ${pmfile} 307 fi 308 done 309 310 exit 0 311