http-apache22 revision 737
278N/A#!/sbin/sh
278N/A#
278N/A# CDDL HEADER START
278N/A#
278N/A# The contents of this file are subject to the terms of the
278N/A# Common Development and Distribution License (the "License").
278N/A# You may not use this file except in compliance with the License.
278N/A#
278N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
278N/A# or http://www.opensolaris.org/os/licensing.
278N/A# See the License for the specific language governing permissions
278N/A# and limitations under the License.
278N/A#
278N/A# When distributing Covered Code, include this CDDL HEADER in each
278N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
278N/A# If applicable, add the following below this CDDL HEADER, with the
278N/A# fields enclosed by brackets "[]" replaced with your own identifying
278N/A# information: Portions Copyright [yyyy] [name of copyright owner]
278N/A#
278N/A# CDDL HEADER END
278N/A#
278N/A#
737N/A# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
278N/A#
278N/A
278N/A. /lib/svc/share/smf_include.sh
278N/A
278N/AAPACHE_VERSION=
278N/AAPACHE_USR_ROOT=/usr/apache2
278N/AAPACHE_ETC_ROOT=/etc/apache2
278N/AAPACHE_VAR_ROOT=/var/apache2
278N/A
278N/A#if startup options contain multiple arguments separated by a blank,
278N/A#then they should be specified as below
278N/A#e.g., %> svccfg -s apache22 setprop 'httpd/startup_options=("-f" "/etc/apache2/2.2/new.conf")'
278N/A#
278N/ASTARTUP_OPTIONS=
278N/A
278N/ASERVER_TYPE=prefork
278N/APLATFORM_DIR=
278N/A
278N/Agetprop() {
278N/A PROPVAL=""
278N/A svcprop -q -p $1 ${SMF_FMRI}
278N/A if [ $? -eq 0 ] ; then
278N/A PROPVAL=`svcprop -p $1 ${SMF_FMRI}`
278N/A if [ "${PROPVAL}" = "\"\"" ] ; then
278N/A PROPVAL=""
278N/A fi
278N/A return
278N/A fi
278N/A return
278N/A}
278N/A
278N/AAPACHE_VERSION=`echo ${SMF_FMRI} | sed 's/[^0-9]//g;s/./\.&/g;s/^\.//'`
278N/Aif [ "x${APACHE_VERSION}" != "x" ]; then
278N/A echo "Apache version is ${APACHE_VERSION}"
278N/A APACHE_USR_ROOT=${APACHE_USR_ROOT}/${APACHE_VERSION}
278N/A APACHE_ETC_ROOT=${APACHE_ETC_ROOT}/${APACHE_VERSION}
278N/A APACHE_VAR_ROOT=${APACHE_VAR_ROOT}/${APACHE_VERSION}
278N/Afi
278N/A
737N/AAPACHE_USER_ENVVARS=${APACHE_ETC_ROOT}/envvars
737N/A
278N/Agetprop httpd/enable_64bit
278N/Aif [ "${PROPVAL}" != "" ] ; then
278N/A case ${PROPVAL} in
278N/A true|1)
278N/A # Check if the system architecture supports 64-bit applications
278N/A PLATFORM=`isainfo -b`
278N/A if [ "${PLATFORM}" != "64" ]; then
278N/A echo "This system is not capable of supporting 64-bit applications."
278N/A echo "Set \"enable_64bit\" property value to \"false\" to start the 32-bit server."
278N/A exit $SMF_EXIT_ERR_CONFIG
278N/A fi
278N/A
278N/A # 64 bit Apache
278N/A PLATFORM_DIR=::ISAINFO::
278N/A ;;
278N/A false|0)
278N/A # 32 bit Apache
278N/A PLATFORM_DIR=
278N/A ;;
278N/A *)
278N/A # Invalid value for "bitness"
278N/A echo "\"bitness\" property value is invalid. Starting the server in 32-bit mode"
278N/A PLATFORM_DIR=
278N/A ;;
278N/A esac
278N/Afi
278N/A
278N/AAPACHE_HOME=${APACHE_USR_ROOT}
278N/AAPACHE_BIN=${APACHE_HOME}/bin${PLATFORM_DIR}
278N/A
278N/Agetprop httpd/startup_options
278N/Aif [ "${PROPVAL}" != "" ] ; then
278N/A echo startupoptions set
278N/A echo val=${PROPVAL}
278N/A STARTUP_OPTIONS="${PROPVAL} -k"
278N/Afi
278N/A
278N/Agetprop httpd/server_type
278N/Aif [ "${PROPVAL}" != "" ] ; then
278N/A SERVER_TYPE=${PROPVAL}
278N/Afi
278N/A
278N/Acase ${SERVER_TYPE} in
278N/Aprefork)
278N/A # If HTTPD value is set in
278N/A # /etc/apache2/<version>/envvars file
278N/A # delete the line so that it defaults to prefork
278N/A # type
737N/A ALREADY_SET=`grep "HTTPD=" ${APACHE_USER_ENVVARS}`
278N/A if [ "${ALREADY_SET}" != "" ]; then
737N/A sed -e '/^HTTPD=/ d' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new
737N/A cp ${APACHE_USER_ENVVARS}.new ${APACHE_USER_ENVVARS}
737N/A rm ${APACHE_USER_ENVVARS}.new
278N/A fi
278N/A ;;
278N/Aworker)
278N/A # set HTTPD value to httpd.worker within
278N/A # /etc/apache2/<version>/envvars file
737N/A ALREADY_SET=`grep "HTTPD=" ${APACHE_USER_ENVVARS}`
278N/A if [ "${ALREADY_SET}" != "" ]; then
278N/A sed -e '/^HTTPD=/c\
737N/AHTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new
278N/A else
278N/A sed -e '$a\
737N/AHTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new
278N/A fi
278N/A
737N/A cp ${APACHE_USER_ENVVARS}.new ${APACHE_USER_ENVVARS}
737N/A rm ${APACHE_USER_ENVVARS}.new
278N/A ;;
278N/A*)
278N/A if [ "x${APACHE_VERSION}" != "x" ]; then
278N/A echo "Unknown server_type"
278N/A exit $SMF_EXIT_ERR_CONFIG
278N/A fi
278N/A ;;
278N/Aesac
278N/A
278N/A
278N/A
278N/Acase "$1" in
278N/Astart)
278N/A cmd="start"
278N/A ;;
278N/Arefresh)
278N/A cmd="graceful"
278N/A ;;
278N/Astop)
278N/A cmd="stop"
278N/A ;;
278N/A*)
278N/A echo "Usage: $0 {start|stop|refresh}"
278N/A exit $SMF_EXIT_ERR_CONFIG
278N/A ;;
278N/Aesac
278N/A
737N/AAPACHE_USER_ENVVARS="${APACHE_USER_ENVVARS}" ${APACHE_BIN}/apachectl ${STARTUP_OPTIONS} ${cmd} 2>&1
278N/A
278N/Aif [ $? -ne 0 ]; then
278N/A echo "Server failed to start. Check the error log (defaults to ${APACHE_VAR_ROOT}/logs/error_log) for more information, if any."
278N/A exit $SMF_EXIT_ERR_FATAL
278N/Afi
278N/A
278N/Aexit $SMF_EXIT_OK