1 #!/usr/bin/ksh93 2 3 # 4 # CDDL HEADER START 5 # 6 # The contents of this file are subject to the terms of the 7 # Common Development and Distribution License (the "License"). 8 # You may not use this file except in compliance with the License. 9 # 10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 # or http://www.opensolaris.org/os/licensing. 12 # See the License for the specific language governing permissions 13 # and limitations under the License. 14 # 15 # When distributing Covered Code, include this CDDL HEADER in each 16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 # If applicable, add the following below this CDDL HEADER, with the 18 # fields enclosed by brackets "[]" replaced with your own identifying 19 # information: Portions Copyright [yyyy] [name of copyright owner] 20 # 21 # CDDL HEADER END 22 # 23 24 # 25 # Copyright 2009 Sun Microsystems, Inc. All rights reserved. 26 # Use is subject to license terms. 27 # 28 #ident "@(#)install-apache2 1.22 09/10/26 SMI" 29 # 30 31 set -o errexit 32 33 . ${SRC}/tools/install.subr 34 . ${SRC}/cmd/apr/apr-1.3/apr.build.env 35 . ${SRC}/cmd/apr-util/apr-util-1.3/apr-util.build.env 36 . ${SRC}/cmd/apache2/apache.build.env 37 38 # functions - search for "START HERE" to find start of control flow 39 40 ins_file() { 41 iprog=$1 42 idir=$2 43 imode=$3 44 _install N ${iprog} ${idir}/${iprog} ${imode} 45 } 46 47 ins_file_modified() { 48 iprog=$1 49 idir=$2 50 idestfile=$3 51 imode=$4 52 _install N ${iprog} ${idir}/${idestfile} ${imode} 53 } 54 55 disable_suexec() { 56 cd ${BINDIR} 57 if [ -f "./suexec" ]; then 58 mv suexec suexec.disabled 59 fi 60 } 61 62 fix_config_files() { 63 set +e 64 cd ${TOP}/Solaris 65 ins_file modules-32.load ${CONFDIR}/conf.d 644 66 67 cd ${CONFDIR} 68 rm -f *.default 69 70 # Strip the 32-bit LoadModule directives from httpd.conf and put them in a 71 # separate file 72 grep "^LoadModule " ${TOP}/Solaris/32/httpd.conf >> conf.d/modules-32.load 73 sed -f ${TOP}/Solaris/32/loadmodules.sed conf.d/modules-32.load > conf.d/modules-32.load.new 74 mv conf.d/modules-32.load.new conf.d/modules-32.load 75 76 # Add <IfModule prefork.c> directives if they are missing 77 HAS_PREFORK_CONFIG=`grep "IfModule prefork.c" httpd.conf` 78 if [ "x${HAS_PREFORK_CONFIG}" = "x" ]; then 79 sed -f ${TOP}/Solaris/httpdconf.sed httpd.conf > httpd.conf.new 80 mv httpd.conf.new httpd.conf 81 fi 82 83 # Rename <sysconfdir>/extra directory to a more intuitive name as 84 # <sysconfdir>/samples-conf.d and remove the duplicate configuration files 85 # in <sysconfdir>/original/extra directory 86 if [ -d ${CONFDIR}/samples-conf.d ]; then 87 rm -rf ${CONFDIR}/samples-conf.d 88 fi 89 mv extra samples-conf.d 90 rm -rf ${CONFDIR}/original/extra 91 92 93 # Rename all the httpd-*.conf files within <sysconfdir>/sample-conf.d dir to 94 # *.conf (no "httpd-" prefix) 95 cd ${CONFDIR}/samples-conf.d 96 for i in *.conf 97 do 98 NEW_CONF_NAME=`echo $i | sed -e '/^httpd-\(.*\).conf/s;^httpd-;;g'` 99 mv $i $NEW_CONF_NAME 100 done 101 102 # Set the appropriate SSLCipherSuite and other values 103 # within ssl.conf file in <sysconfdir>/samples-conf.d directory 104 sed -f ${TOP}/Solaris/sslconf.sed ssl.conf > ssl.conf.new 105 mv ssl.conf.new ssl.conf 106 107 cd ${BINDIR} 108 if [ ! -f ${CONFDIR}/envvars ]; then 109 grep "^#" envvars > ${CONFDIR}/envvars 110 fi 111 112 # Add logic to source the user-customizable envvars file 113 ENVVAR_INCLUDE=`grep "/envvars" envvars` 114 if [ "x${ENVVAR_INCLUDE}" = "x" ]; then 115 sed -f ${TOP}/Solaris/envvars.sed envvars > envvars.1 116 mv envvars.1 envvars 117 fi 118 set -e 119 } 120 121 install_real_bins() { 122 cd ${TOP}/${APACHE_WORKER_DIR}/.libs 123 ins_file_modified httpd ${BINDIR} httpd.worker 555 124 125 cd ${TOP}/${APACHE_PREFORK_DIR}/.libs 126 ins_file httpd ${BINDIR} 555 127 128 cd ${TOP}/${APACHE_PREFORK_DIR}/support/.libs 129 for i in \ 130 ab \ 131 checkgid \ 132 htcacheclean \ 133 htdbm \ 134 htdigest \ 135 htpasswd \ 136 httxt2dbm \ 137 logresolve \ 138 rotatelogs 139 do 140 ins_file ${i} ${BINDIR} 555 141 done 142 } 143 144 install_smf_hooks() { 145 cd ${TOP}/Solaris 146 ins_file http-apache22.xml ${ROOT}/var/svc/manifest/network 444 147 } 148 149 install_auth_gss() { 150 cd ${MOD_AUTH_GSS_DIR} 151 ins_file mod_auth_gss.so ${LIBEXECDIR} 555 152 } 153 154 post_process() { 155 cd ${BINDIR} 156 for i in \ 157 ab \ 158 checkgid \ 159 htcacheclean \ 160 htdbm \ 161 htdigest \ 162 htpasswd \ 163 httpd \ 164 httpd.worker \ 165 httxt2dbm \ 166 logresolve \ 167 rotatelogs \ 168 suexec.disabled 169 do 170 chmod u+w ${i} 171 ${SRC}/tools/post_process ${i} 172 chmod u-w ${i} 173 done 174 175 cd ${LIBEXECDIR} 176 for i in *.so 177 do 178 chmod u+w ${i} 179 ${SRC}/tools/post_process_so ${i} 180 chmod u-w ${i} 181 done 182 } 183 184 cleanup_crud() { 185 rm -rf ${ROOT}${VARDIR} 186 } 187 188 fix_apache_perms() { 189 190 cd ${CONFDIR} 191 find . -type f -exec chmod 644 {} \; 192 193 cd ${PREFIX} 194 APDIRS="man manual" 195 find ${APDIRS} -type d -exec chmod 755 {} \; 196 find ${APDIRS} -type f -exec chmod 644 {} \; 197 198 cd ${PREFIX} 199 APDIRS="bin build include lib libexec" 200 find ${APDIRS} -type d -exec chmod 755 {} \; 201 find ${APDIRS} -type f -exec chmod 555 {} \; 202 203 cd ${BINDIR} 204 find . -type f -name envvars -exec chmod 644 {} \; 205 find . -type f -name envvars-std -exec chmod 444 {} \; 206 find . -type f -name suexec.disabled -exec chmod 700 {} \; 207 208 cd ${INCLUDEDIR} 209 find . -type f -exec chmod 644 {} \; 210 211 cd ${VARDIR} 212 APDIRS="cgi-bin error htdocs icons logs proxy" 213 find ${APDIRS} -type d -exec chmod 755 {} \; 214 find ${APDIRS} -type f -exec chmod 644 {} \; 215 216 chmod 755 ${VARDIR}/proxy 217 chmod 755 ${VARDIR}/logs 218 } 219 220 # apache2 stores all kinds of info about the build environment 221 # in $ROOT/usr/apache2/build. We need to massage this so it 222 # is all relative to an installed machine, rather than a build 223 # proto area. 224 fix_build_config() { 225 cd ${BUILDDIR} 226 ${GPATCH} ${GPATCH_FLAGS} < ${TOP}/patches/32/rules.mk.patch.install 227 ${GPATCH} ${GPATCH_FLAGS} < ${TOP}/patches/32/special.mk.patch.install 228 } 229 230 fix_perl_paths() { 231 cd ${VARDIR} 232 _fixup_perl cgi-bin/printenv 233 } 234 235 # install Apache commonly used man pages 236 install_man_files() { 237 cd ${MAN8DIR} 238 for i in *.8 239 do 240 ins_file $i ${ROOT}/usr/share/man/man8 444 241 done 242 243 cd ${TOP}/Solaris 244 ins_file_modified apache2.1m.sunman ${ROOT}/usr/share/man/man1m apache2.1m 444 245 } 246 247 # install favicon files under default docroot 248 install_favicon_files() { 249 cd ${TOP}/Solaris 250 ins_file favicon.gif ${VARDIR}/htdocs 644 251 ins_file favicon.ico ${VARDIR}/htdocs 644 252 } 253 254 # create soft links to the binaries in ${BINDIR} from /usr/bin 255 # e.g., /usr/bin/ab --> /usr/apache2/2.2/bin/ab 256 create_bin_links() { 257 cd ${BINDIR} 258 for i in \ 259 ab \ 260 apxs \ 261 dbmmanage \ 262 htcacheclean \ 263 htdbm \ 264 htdigest \ 265 htpasswd \ 266 httxt2dbm \ 267 logresolve \ 268 mp2bug \ 269 rotatelogs 270 do 271 _install L ../${APACHE_DIR_PREFIX}/bin/${i} ${ROOT}/usr/bin/${i} 272 done 273 } 274 275 # replace build environment specific paths 276 replace_build_path() { 277 cd ${BUILDDIR} 278 for i in `ls -Lp | grep -v '/$'`; do 279 sed -e "s;${ROOT};;g" \ 280 -e "s;-M ${MAPFILE_NOEXSTK} ;;g" \ 281 -e "s;${SPRO_VROOT}/bin/;;g" \ 282 -e "s;${APR_SRC_DIR32};${APR_USR_PREFIX};g" \ 283 -e "s;${APR_UTIL_SRC_DIR32};${APR_UTIL_USR_PREFIX};g" \ 284 -e "s;${APACHE_SRC_PREFORK_DIR32};${APACHE_USR_PREFIX};g" \ 285 -e "s;${APACHE_SRC_WORKER_DIR32};${APACHE_USR_PREFIX};g" < ${i} > ${i}.tmp 286 cp -f ${i}.tmp ${i} 287 rm -f ${i}.tmp 288 done 289 } 290 291 # remove the bundled but disabled (by default) modules from modules-32.load 292 remove_disabled_modules() { 293 cd ${TOP}/Solaris 294 sed -e 's/#.*//' -e '/^$/ d' ./disabled-module.list > ./tmp-disabled.list 295 for i in `cat ./tmp-disabled.list`; do 296 sed -e '/LoadModule.*'${i}'.so/ d' ${CONFDIR}/conf.d/modules-32.load > ${CONFDIR}/conf.d/tmp-32.load 297 mv ${CONFDIR}/conf.d/tmp-32.load ${CONFDIR}/conf.d/modules-32.load 298 done 299 rm -f ./tmp-disabled.list 300 } 301 302 # create a sample .conf file for every bundled but disabled modules listed 303 # in "Solaris/module_exclude.list" file 304 create_sample_module_conf() { 305 cd ${TOP}/Solaris 306 sed -e 's/#.*//' -e '/^$/ d' ./disabled-module.list > ./tmp-disabled.list 307 for i in `cat ./tmp-disabled.list`; do 308 module_name=`echo ${i} | sed -e 's/^mod_//'` 309 if test -f ${CONFDIR}/samples-conf.d/${module_name}.conf; then 310 rm -f ${CONFDIR}/samples-conf.d/${module_name}.conf 311 fi 312 sed -e 's/::MODULE_NAME::/'${module_name}'/g' ./sample-module.tmpl \ 313 > ${CONFDIR}/samples-conf.d/${module_name}.conf 314 done 315 rm -f ./tmp-disabled.list 316 } 317 318 # START HERE - actual script processing starts here 319 320 # Even though this is called "install-apache", it doesn't really 321 # install the whole thing. Much of apache itself is installed by 322 # make install - we need to fix permissions. What we install here 323 # are modules that apache won't install as part of its normal build. 324 # Each install task is a function, so it's relatively easy to add new 325 # stuff. 326 327 TOP=`pwd` 328 329 PREFIX=${ROOT}${APACHE_USR_PREFIX} 330 CONFDIR=${ROOT}${APACHE_ETC_PREFIX} 331 VARDIR=${ROOT}${APACHE_VAR_PREFIX} 332 INCLUDEDIR=${PREFIX}/include 333 HTDOCS=${VARDIR}/htdocs 334 MANUAL_HTDOCS=${PREFIX}/manual 335 MANDIR=${PREFIX}/man 336 MAN1DIR=${MANDIR}/man1 337 MAN3DIR=${MANDIR}/man3 338 MAN8DIR=${MANDIR}/man8 339 ETC=${ROOT}/etc 340 RIGHTSDIR=${ROOT}/etc/security 341 342 BINDIR=${PREFIX}/bin 343 BUILDDIR=${PREFIX}/build 344 LIBDIR=${PREFIX}/lib 345 LIBEXECDIR=${PREFIX}/libexec 346 MOD_AUTH_GSS_DIR=${TOP}/mod_auth_gss/.libs 347 APACHE_SRC_PREFORK_DIR32=${TOP}/${APACHE_PREFORK_DIR} 348 APACHE_SRC_WORKER_DIR32=${TOP}/${APACHE_WORKER_DIR} 349 APR_SRC_DIR32=${SRC}/cmd/apr/apr-${APR_VERSION_DIR}/${APR_DIR32} 350 APR_UTIL_SRC_DIR32=${SRC}/cmd/apr-util/apr-util-${APR_UTIL_VERSION_DIR}/${APR_UTIL_DIR32} 351 352 disable_suexec 353 install_real_bins 354 fix_config_files 355 install_smf_hooks 356 install_auth_gss 357 post_process 358 cleanup_crud 359 fix_build_config 360 fix_perl_paths 361 install_man_files 362 install_favicon_files 363 remove_disabled_modules 364 create_sample_module_conf 365 replace_build_path 366 367 # all installation should be done before this point, so the functions 368 # that fixup permissions can get everything that is installed. 369 370 fix_apache_perms 371 create_bin_links 372 373 exit 0 374