|
1 #!/sbin/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 (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
24 # |
|
25 |
|
26 . /lib/svc/share/smf_include.sh |
|
27 |
|
28 APACHE_VERSION= |
|
29 APACHE_USR_ROOT=/usr/apache2 |
|
30 APACHE_ETC_ROOT=/etc/apache2 |
|
31 APACHE_VAR_ROOT=/var/apache2 |
|
32 |
|
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")' |
|
36 # |
|
37 STARTUP_OPTIONS= |
|
38 |
|
39 getprop() { |
|
40 PROPVAL="" |
|
41 svcprop -q -p $1 ${SMF_FMRI} |
|
42 if [ $? -eq 0 ] ; then |
|
43 PROPVAL=`svcprop -p $1 ${SMF_FMRI}` |
|
44 if [ "${PROPVAL}" = "\"\"" ] ; then |
|
45 PROPVAL="" |
|
46 fi |
|
47 return |
|
48 fi |
|
49 return |
|
50 } |
|
51 |
|
52 # Check whether alternate config file was specified using option -f. |
|
53 # If it's the case, Apache will search in the same directory for |
|
54 # availability of environment file. |
|
55 envvars_path_update() { |
|
56 eval "set -- $1" |
|
57 while [ $# -gt 0 ]; do |
|
58 case "$1" in |
|
59 -f) APACHE_USER_ENVVARS=`dirname "${2:-}"`/envvars; break;; |
|
60 -f*) APACHE_USER_ENVVARS=`dirname "${1#-f}"`/envvars; break;; |
|
61 esac |
|
62 shift |
|
63 done |
|
64 } |
|
65 |
|
66 APACHE_VERSION=`echo ${SMF_FMRI} | sed 's/[^0-9]//g;s/./\.&/g;s/^\.//'` |
|
67 if [ "x${APACHE_VERSION}" != "x" ]; then |
|
68 echo "Apache version is ${APACHE_VERSION}" |
|
69 APACHE_USR_ROOT=${APACHE_USR_ROOT}/${APACHE_VERSION} |
|
70 APACHE_ETC_ROOT=${APACHE_ETC_ROOT}/${APACHE_VERSION} |
|
71 APACHE_VAR_ROOT=${APACHE_VAR_ROOT}/${APACHE_VERSION} |
|
72 fi |
|
73 |
|
74 APACHE_USER_ENVVARS=${APACHE_ETC_ROOT}/envvars |
|
75 |
|
76 APACHE_HOME=${APACHE_USR_ROOT} |
|
77 APACHE_BIN=${APACHE_HOME}/bin |
|
78 HTTPD=${APACHE_BIN}/httpd |
|
79 |
|
80 getprop httpd/startup_options |
|
81 if [ "${PROPVAL}" != "" ] ; then |
|
82 echo startupoptions set |
|
83 echo val=${PROPVAL} |
|
84 STARTUP_OPTIONS="${PROPVAL} -k" |
|
85 envvars_path_update "${PROPVAL}" |
|
86 fi |
|
87 |
|
88 getprop httpd/MPM |
|
89 if [ "${PROPVAL}x" == "workerx" ] || [ "${PROPVAL}x" == "preforkx" ] ; then |
|
90 HTTPD="${HTTPD} -D ${PROPVAL}" |
|
91 fi |
|
92 |
|
93 case "$1" in |
|
94 start) |
|
95 cmd="start" |
|
96 ;; |
|
97 refresh) |
|
98 cmd="graceful" |
|
99 ;; |
|
100 stop) |
|
101 cmd="stop" |
|
102 ;; |
|
103 *) |
|
104 echo "Usage: $0 {start|stop|refresh}" |
|
105 exit $SMF_EXIT_ERR_CONFIG |
|
106 ;; |
|
107 esac |
|
108 |
|
109 HTTPD="${HTTPD}" APACHE_USER_ENVVARS="${APACHE_USER_ENVVARS}" ${APACHE_BIN}/apachectl ${STARTUP_OPTIONS} ${cmd} 2>&1 |
|
110 |
|
111 if [ $? -ne 0 ]; then |
|
112 echo "Server failed to start. Check the error log (defaults to ${APACHE_VAR_ROOT}/logs/error_log) for more information, if any." |
|
113 exit $SMF_EXIT_ERR_FATAL |
|
114 fi |
|
115 |
|
116 exit $SMF_EXIT_OK |