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.
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.
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]
23 # Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
26 .
/lib
/svc
/share
/smf_include.sh
29 APACHE_USR_ROOT
=/usr
/apache2
30 APACHE_ETC_ROOT
=/etc
/apache2
31 APACHE_VAR_ROOT
=/var
/apache2
33 #if startup options contain multiple arguments separated by a blank,
34 #then they should be specified as below
35 #e.g., %> svccfg -s apache24 setprop 'httpd/startup_options=("-f" "/etc/apache2/2.4/new.conf")'
44 svcprop
-q -p $1 ${SMF_FMRI}
45 if [ $?
-eq 0 ] ; then
46 PROPVAL
=`svcprop -p $1 ${SMF_FMRI}`
47 if [ "${PROPVAL}" = "\"\"" ] ; then
55 APACHE_VERSION
=`echo ${SMF_FMRI} | sed 's/[^0-9]//g;s/./\.&/g;s/^\.//'`
56 if [ "x${APACHE_VERSION}" != "x" ]; then
57 echo "Apache version is ${APACHE_VERSION}"
58 APACHE_USR_ROOT
=${APACHE_USR_ROOT}/${APACHE_VERSION}
59 APACHE_ETC_ROOT
=${APACHE_ETC_ROOT}/${APACHE_VERSION}
60 APACHE_VAR_ROOT
=${APACHE_VAR_ROOT}/${APACHE_VERSION}
63 APACHE_USER_ENVVARS
=${APACHE_ETC_ROOT}/envvars
65 getprop httpd
/enable_64bit
66 if [ "${PROPVAL}" != "" ] ; then
69 # Check if the system architecture supports 64-bit applications
71 if [ "${PLATFORM}" != "64" ]; then
72 echo "This system is not capable of supporting 64-bit applications."
73 echo "Set \"enable_64bit\" property value to \"false\" to start the 32-bit server."
74 exit $SMF_EXIT_ERR_CONFIG
78 PLATFORM_DIR
=::ISAINFO
::
85 # Invalid value for "bitness"
86 echo "\"bitness\" property value is invalid. Starting the server in 32-bit mode"
92 APACHE_HOME
=${APACHE_USR_ROOT}
93 APACHE_BIN
=${APACHE_HOME}/bin
${PLATFORM_DIR}
95 getprop httpd
/startup_options
96 if [ "${PROPVAL}" != "" ] ; then
97 echo startupoptions
set
99 STARTUP_OPTIONS
="${PROPVAL} -k"
102 getprop httpd
/server_type
103 if [ "${PROPVAL}" != "" ] ; then
104 SERVER_TYPE
=${PROPVAL}
107 case ${SERVER_TYPE} in
109 # If HTTPD value is set in
110 # /etc/apache2/<version>/envvars file
111 # delete the line so that it defaults to prefork
113 ALREADY_SET
=`grep "HTTPD=" ${APACHE_USER_ENVVARS}`
114 if [ "${ALREADY_SET}" != "" ]; then
115 sed -e '/^HTTPD=/ d' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new
116 cp ${APACHE_USER_ENVVARS}.new
${APACHE_USER_ENVVARS}
117 rm ${APACHE_USER_ENVVARS}.new
121 # set HTTPD value to httpd.worker within
122 # /etc/apache2/<version>/envvars file
123 ALREADY_SET
=`grep "HTTPD=" ${APACHE_USER_ENVVARS}`
124 if [ "${ALREADY_SET}" != "" ]; then
126 HTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new
129 HTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new
132 cp ${APACHE_USER_ENVVARS}.new
${APACHE_USER_ENVVARS}
133 rm ${APACHE_USER_ENVVARS}.new
136 if [ "x${APACHE_VERSION}" != "x" ]; then
137 echo "Unknown server_type"
138 exit $SMF_EXIT_ERR_CONFIG
156 echo "Usage: $0 {start|stop|refresh}"
157 exit $SMF_EXIT_ERR_CONFIG
161 APACHE_USER_ENVVARS
="${APACHE_USER_ENVVARS}" ${APACHE_BIN}/apachectl ${STARTUP_OPTIONS} ${cmd} 2>&1
163 if [ $? -ne 0 ]; then
164 echo "Server failed to start. Check the error log
(defaults to
${APACHE_VAR_ROOT}/logs
/error_log
) for more information
, if any.
"
165 exit $SMF_EXIT_ERR_FATAL