30 APACHE_ETC_ROOT=/etc/apache2 |
30 APACHE_ETC_ROOT=/etc/apache2 |
31 APACHE_VAR_ROOT=/var/apache2 |
31 APACHE_VAR_ROOT=/var/apache2 |
32 |
32 |
33 #if startup options contain multiple arguments separated by a blank, |
33 #if startup options contain multiple arguments separated by a blank, |
34 #then they should be specified as below |
34 #then they should be specified as below |
35 #e.g., %> svccfg -s apache22 setprop httpd/startup_options=\("-f" "/etc/apache2/2.2/new.conf"\) |
35 #e.g., %> svccfg -s apache22 setprop 'httpd/startup_options=("-f" "/etc/apache2/2.2/new.conf")' |
36 # |
36 # |
37 STARTUP_OPTIONS= |
37 STARTUP_OPTIONS= |
38 |
38 |
39 SERVER_TYPE=prefork |
39 SERVER_TYPE=prefork |
40 PLATFORM_DIR= |
40 PLATFORM_DIR= |
48 PROPVAL="" |
48 PROPVAL="" |
49 fi |
49 fi |
50 return |
50 return |
51 fi |
51 fi |
52 return |
52 return |
53 } |
|
54 |
|
55 # Check whether alternate config file was specified using option -f. |
|
56 # If it's the case, Apache will search in the same directory for |
|
57 # availability of environment file. |
|
58 envvars_path_update() { |
|
59 eval "set -- $1" |
|
60 while [ $# -gt 0 ]; do |
|
61 case "$1" in |
|
62 -f) APACHE_USER_ENVVARS=`dirname "${2:-}"`/envvars; break;; |
|
63 -f*) APACHE_USER_ENVVARS=`dirname "${1#-f}"`/envvars; break;; |
|
64 esac |
|
65 shift |
|
66 done |
|
67 } |
53 } |
68 |
54 |
69 APACHE_VERSION=`echo ${SMF_FMRI} | sed 's/[^0-9]//g;s/./\.&/g;s/^\.//'` |
55 APACHE_VERSION=`echo ${SMF_FMRI} | sed 's/[^0-9]//g;s/./\.&/g;s/^\.//'` |
70 if [ "x${APACHE_VERSION}" != "x" ]; then |
56 if [ "x${APACHE_VERSION}" != "x" ]; then |
71 echo "Apache version is ${APACHE_VERSION}" |
57 echo "Apache version is ${APACHE_VERSION}" |
109 getprop httpd/startup_options |
95 getprop httpd/startup_options |
110 if [ "${PROPVAL}" != "" ] ; then |
96 if [ "${PROPVAL}" != "" ] ; then |
111 echo startupoptions set |
97 echo startupoptions set |
112 echo val=${PROPVAL} |
98 echo val=${PROPVAL} |
113 STARTUP_OPTIONS="${PROPVAL} -k" |
99 STARTUP_OPTIONS="${PROPVAL} -k" |
114 envvars_path_update "${PROPVAL}" |
|
115 fi |
100 fi |
116 |
101 |
117 getprop httpd/server_type |
102 getprop httpd/server_type |
118 if [ "${PROPVAL}" != "" ] ; then |
103 if [ "${PROPVAL}" != "" ] ; then |
119 SERVER_TYPE=${PROPVAL} |
104 SERVER_TYPE=${PROPVAL} |
120 fi |
105 fi |
121 |
106 |
122 case ${SERVER_TYPE} in |
107 case ${SERVER_TYPE} in |
123 prefork) |
108 prefork) |
124 HTTPD=${APACHE_BIN}/httpd |
109 # If HTTPD value is set in |
|
110 # /etc/apache2/<version>/envvars file |
|
111 # delete the line so that it defaults to prefork |
|
112 # type |
|
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 |
|
118 fi |
125 ;; |
119 ;; |
126 worker) |
120 worker) |
127 HTTPD=${APACHE_BIN}/httpd.worker |
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 |
|
125 sed -e '/^HTTPD=/c\ |
|
126 HTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new |
|
127 else |
|
128 sed -e '$a\ |
|
129 HTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_USER_ENVVARS} > ${APACHE_USER_ENVVARS}.new |
|
130 fi |
|
131 |
|
132 cp ${APACHE_USER_ENVVARS}.new ${APACHE_USER_ENVVARS} |
|
133 rm ${APACHE_USER_ENVVARS}.new |
128 ;; |
134 ;; |
129 *) |
135 *) |
130 if [ "x${APACHE_VERSION}" != "x" ]; then |
136 if [ "x${APACHE_VERSION}" != "x" ]; then |
131 echo "Unknown server_type" |
137 echo "Unknown server_type" |
132 exit $SMF_EXIT_ERR_CONFIG |
138 exit $SMF_EXIT_ERR_CONFIG |
150 echo "Usage: $0 {start|stop|refresh}" |
156 echo "Usage: $0 {start|stop|refresh}" |
151 exit $SMF_EXIT_ERR_CONFIG |
157 exit $SMF_EXIT_ERR_CONFIG |
152 ;; |
158 ;; |
153 esac |
159 esac |
154 |
160 |
155 HTTPD="${HTTPD}" APACHE_USER_ENVVARS="${APACHE_USER_ENVVARS}" ${APACHE_BIN}/apachectl ${STARTUP_OPTIONS} ${cmd} 2>&1 |
161 APACHE_USER_ENVVARS="${APACHE_USER_ENVVARS}" ${APACHE_BIN}/apachectl ${STARTUP_OPTIONS} ${cmd} 2>&1 |
156 |
162 |
157 if [ $? -ne 0 ]; then |
163 if [ $? -ne 0 ]; then |
158 echo "Server failed to start. Check the error log (defaults to ${APACHE_VAR_ROOT}/logs/error_log) for more information, if any." |
164 echo "Server failed to start. Check the error log (defaults to ${APACHE_VAR_ROOT}/logs/error_log) for more information, if any." |
159 exit $SMF_EXIT_ERR_FATAL |
165 exit $SMF_EXIT_ERR_FATAL |
160 fi |
166 fi |