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#
3158N/A# Copyright (c) 2014, 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
3158N/A#e.g., %> svccfg -s apache24 setprop httpd/startup_options=\("-f" "/etc/apache2/2.4/new.conf"\)
278N/A#
278N/ASTARTUP_OPTIONS=
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
1784N/A# Check whether alternate config file was specified using option -f.
1784N/A# If it's the case, Apache will search in the same directory for
1784N/A# availability of environment file.
1784N/Aenvvars_path_update() {
1784N/A eval "set -- $1"
1784N/A while [ $# -gt 0 ]; do
1784N/A case "$1" in
1784N/A -f) APACHE_USER_ENVVARS=`dirname "${2:-}"`/envvars; break;;
1784N/A -f*) APACHE_USER_ENVVARS=`dirname "${1#-f}"`/envvars; break;;
1784N/A esac
1784N/A shift
1784N/A done
1784N/A}
1784N/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/AAPACHE_HOME=${APACHE_USR_ROOT}
3158N/AAPACHE_BIN=${APACHE_HOME}/bin
3158N/AHTTPD=${APACHE_BIN}/httpd
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"
1784N/A envvars_path_update "${PROPVAL}"
278N/Afi
278N/A
3158N/Agetprop httpd/MPM
3158N/Aif [ "${PROPVAL}x" == "workerx" ] || [ "${PROPVAL}x" == "preforkx" ] ; then
3158N/A HTTPD="${HTTPD} -D ${PROPVAL}"
278N/Afi
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
1784N/AHTTPD="${HTTPD}" APACHE_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