| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# High-Availability Apache/IBMhttp control script |
| 4 |
# |
| 5 |
# apache (aka IBMhttpd) |
| 6 |
# |
| 7 |
# Description: starts/stops apache web servers. |
| 8 |
# |
| 9 |
# Author: Alan Robertson |
| 10 |
# Sun Jiang Dong |
| 11 |
# |
| 12 |
# Support: [email protected] |
| 13 |
# |
| 14 |
# License: GNU General Public License (GPL) |
| 15 |
# |
| 16 |
# Copyright: (C) 2002-2005 International Business Machines |
| 17 |
# |
| 18 |
# |
| 19 |
# An example usage in /etc/ha.d/haresources: |
| 20 |
# node1 10.0.0.170 apache::/opt/IBMHTTPServer/conf/httpd.conf |
| 21 |
# node1 10.0.0.170 IBMhttpd |
| 22 |
# |
| 23 |
# Our parsing of the Apache config files is very rudimentary. |
| 24 |
# It'll work with lots of different configurations - but not every |
| 25 |
# possible configuration. |
| 26 |
# |
| 27 |
# Patches are being accepted ;-) |
| 28 |
# |
| 29 |
# OCF parameters: |
| 30 |
# OCF_RESKEY_configfile |
| 31 |
# OCF_RESKEY_httpd |
| 32 |
# OCF_RESKEY_port |
| 33 |
# OCF_RESKEY_statusurl |
| 34 |
# OCF_RESKEY_options |
| 35 |
# OCF_RESKEY_testregex |
| 36 |
# OCF_RESKEY_client |
| 37 |
# OCF_RESKEY_testurl |
| 38 |
# OCF_RESKEY_testregex10 |
| 39 |
# OCF_RESKEY_testconffile |
| 40 |
# OCF_RESKEY_testname |
| 41 |
# OCF_RESKEY_envfiles |
| 42 |
|
| 43 |
|
| 44 |
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} |
| 45 |
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs |
| 46 |
. ${OCF_FUNCTIONS_DIR}/apache-conf.sh |
| 47 |
. ${OCF_FUNCTIONS_DIR}/http-mon.sh |
| 48 |
HA_VARRUNDIR=${HA_VARRUN} |
| 49 |
|
| 50 |
# Parameter defaults |
| 51 |
|
| 52 |
OCF_RESKEY_httpd_default="/usr/sbin/httpd" |
| 53 |
OCF_RESKEY_envfiles_default="/etc/apache2/envvars" |
| 54 |
OCF_RESKEY_use_ipv6_default="false" |
| 55 |
|
| 56 |
####################################################################### |
| 57 |
# |
| 58 |
# Configuration options - usually you don't need to change these |
| 59 |
# |
| 60 |
####################################################################### |
| 61 |
# |
| 62 |
IBMHTTPD=/opt/IBMHTTPServer/bin/httpd |
| 63 |
HTTPDLIST="/sbin/httpd2 /usr/sbin/httpd2 /usr/sbin/apache2 /sbin/httpd /usr/sbin/httpd /usr/sbin/apache $IBMHTTPD" |
| 64 |
MPM=/usr/share/apache2/find_mpm |
| 65 |
if [ -x $MPM ]; then |
| 66 |
HTTPDLIST="$HTTPDLIST `$MPM 2>/dev/null`" |
| 67 |
fi |
| 68 |
|
| 69 |
LOCALHOST="http://localhost" |
| 70 |
HTTPDOPTS="-DSTATUS" |
| 71 |
DEFAULT_IBMCONFIG=/opt/IBMHTTPServer/conf/httpd.conf |
| 72 |
DEFAULT_SUSECONFIG="/etc/apache2/httpd.conf" |
| 73 |
DEFAULT_RHELCONFIG="/etc/httpd/conf/httpd.conf" |
| 74 |
DEFAULT_DEBIANCONFIG="/etc/apache2/apache2.conf" |
| 75 |
# |
| 76 |
# You can also set |
| 77 |
# HTTPD |
| 78 |
# PORT |
| 79 |
# STATUSURL |
| 80 |
# CONFIGFILE |
| 81 |
# in this section if what we're doing doesn't work for you... |
| 82 |
# |
| 83 |
# End of Configuration options |
| 84 |
####################################################################### |
| 85 |
|
| 86 |
CMD=`basename $0` |
| 87 |
|
| 88 |
# The config-file-pathname is the pathname to the configuration |
| 89 |
# file for this web server. Various appropriate defaults are |
| 90 |
# assumed if no config file is specified. If this command is |
| 91 |
# invoked as *IBM*, then the default config file name is |
| 92 |
# $DEFAULT_IBMCONFIG, otherwise the default config file |
| 93 |
# will be either $DEFAULT_RHELCONFIG or $DEFAULT_SUSECONFIG depending |
| 94 |
# on which is detected. |
| 95 |
usage() { |
| 96 |
cat <<-END |
| 97 |
usage: $0 action |
| 98 |
|
| 99 |
action: |
| 100 |
start start the web server |
| 101 |
|
| 102 |
stop stop the web server |
| 103 |
|
| 104 |
status return the status of web server, run or down |
| 105 |
|
| 106 |
monitor return TRUE if the web server appears to be working. |
| 107 |
For this to be supported you must configure mod_status |
| 108 |
and give it a server-status URL. You have to have |
| 109 |
installed either curl or wget for this to work. |
| 110 |
|
| 111 |
meta-data show meta data message |
| 112 |
|
| 113 |
validate-all validate the instance parameters |
| 114 |
END |
| 115 |
} |
| 116 |
|
| 117 |
get_pid() { |
| 118 |
if [ -f $PidFile ]; then |
| 119 |
cat $PidFile |
| 120 |
else |
| 121 |
false |
| 122 |
fi |
| 123 |
} |
| 124 |
# |
| 125 |
# return TRUE if a process with given PID is running |
| 126 |
# |
| 127 |
ProcessRunning() { |
| 128 |
local pid=$1 |
| 129 |
|
| 130 |
# Use /proc if it looks like it's here... |
| 131 |
if [ -d /proc -a -d /proc/1 ]; then |
| 132 |
[ -d /proc/$pid ] |
| 133 |
else |
| 134 |
# This assumes we're running as root... |
| 135 |
kill -s 0 "$pid" >/dev/null 2>&1 |
| 136 |
fi |
| 137 |
} |
| 138 |
silent_status() { |
| 139 |
local pid |
| 140 |
local rc=$OCF_ERR_GENERIC |
| 141 |
local retries=0 |
| 142 |
|
| 143 |
# Set a retry when apache's Graceful restart is applied and the pid file can not be acquired. |
| 144 |
if [ "$__OCF_ACTION" = "monitor" ] && ! ocf_is_probe; then |
| 145 |
retries=5 |
| 146 |
fi |
| 147 |
|
| 148 |
while true; do |
| 149 |
pid=`get_pid` |
| 150 |
if [ -n "$pid" ]; then |
| 151 |
ProcessRunning $pid |
| 152 |
rc=$? |
| 153 |
break |
| 154 |
fi |
| 155 |
|
| 156 |
: No pid file |
| 157 |
if [ $retries -le 0 ]; then |
| 158 |
break |
| 159 |
fi |
| 160 |
|
| 161 |
sleep 1 |
| 162 |
retries=`expr $retries - 1` |
| 163 |
done |
| 164 |
|
| 165 |
return $rc |
| 166 |
} |
| 167 |
|
| 168 |
# May be useful to add other distros in future |
| 169 |
validate_default_config() { |
| 170 |
if is_suse_based; then |
| 171 |
validate_default_suse_config |
| 172 |
elif is_debian_based; then |
| 173 |
validate_default_debian_config |
| 174 |
else |
| 175 |
return 0 |
| 176 |
fi |
| 177 |
} |
| 178 |
|
| 179 |
# When using the default /etc/apache2/httpd.conf on SUSE, the file |
| 180 |
# /etc/apache2/sysconfig.d/include.conf is required to be present, |
| 181 |
# but this is only generated if you run the apache init script |
| 182 |
# (with contents derived from /etc/sysconfig/apache2). So, here, |
| 183 |
# if we're using the default system config file and it requires |
| 184 |
# that include, we run "/etc/init.d/apache2 configtest" to ensure |
| 185 |
# the relevant config is generated and valid. We're also taking |
| 186 |
# this opportunity to enable mod_status if it's not present. |
| 187 |
validate_default_suse_config() { |
| 188 |
if [ "$CONFIGFILE" = "$DEFAULT_SUSECONFIG" ] && \ |
| 189 |
grep -Eq '^Include[[:space:]]+/etc/apache2/sysconfig.d/include.conf' "$CONFIGFILE" |
| 190 |
then |
| 191 |
[ -x "/usr/sbin/a2enmod" ] && ocf_run -q /usr/sbin/a2enmod status |
| 192 |
# init script style, for crusty old SUSE |
| 193 |
if [ -x "/etc/init.d/apache2" ]; then |
| 194 |
ocf_run -q /etc/init.d/apache2 configtest || return 1 |
| 195 |
# systemd style, for shiny new SUSE |
| 196 |
elif [ -x "/usr/sbin/start_apache2" ]; then |
| 197 |
ocf_run -q /usr/sbin/start_apache2 -t || return 1 |
| 198 |
fi |
| 199 |
fi |
| 200 |
|
| 201 |
# mod_status: some existing users might don't want to use mod_status, check if present in configuration |
| 202 |
if [ "$CONFIGFILE" = "$DEFAULT_SUSECONFIG" ] && \ |
| 203 |
grep -Eq '^Include[[:space:]]+/etc/apache2/mod_status.conf' "$CONFIGFILE" |
| 204 |
then |
| 205 |
# load module only if module exists |
| 206 |
apache_mod_status="/usr/lib64/apache2-prefork/mod_status.so" |
| 207 |
if [ -e $apache_mod_status ]; then |
| 208 |
LOAD_STATUS_MODULE="LoadModule status_module $apache_mod_status" |
| 209 |
fi |
| 210 |
fi |
| 211 |
return 0 |
| 212 |
} |
| 213 |
|
| 214 |
# Debian's Default configuration uses a lock directory /var/lock/apache2 |
| 215 |
# which is only generated using the lsb init script issues configtest. To |
| 216 |
# ensure these default directories are present it's useful to run a configtest |
| 217 |
# prior to the resource startup which will create the needed directories |
| 218 |
# |
| 219 |
# To support multiple apache instances the debian scripts and configs |
| 220 |
# obey apache2/envvars. (copy /etc/apache2 -> /etc/apache2-instance) |
| 221 |
# adjust (SUFFIX) envvars and set OCF_RESKEY_envfiles |
| 222 |
validate_default_debian_config() { |
| 223 |
if find /etc/apache2* -name apache2.conf | grep -q "$CONFIGFILE" |
| 224 |
then |
| 225 |
export APACHE_CONFDIR=$(dirname $CONFIGFILE) |
| 226 |
[ -x "/usr/sbin/a2enmod" ] && ocf_run -q /usr/sbin/a2enmod status |
| 227 |
ocf_run -q /usr/sbin/apache2ctl configtest || return 1 |
| 228 |
fi |
| 229 |
return 0 |
| 230 |
} |
| 231 |
|
| 232 |
apache_start() { |
| 233 |
if |
| 234 |
silent_status |
| 235 |
then |
| 236 |
ocf_log info "$CMD already running (pid `get_pid`)" |
| 237 |
return $OCF_SUCCESS |
| 238 |
fi |
| 239 |
|
| 240 |
validate_default_config || return $OCF_ERR_CONFIGURED |
| 241 |
|
| 242 |
if [ -z $PIDFILE_DIRECTIVE ]; then |
| 243 |
if [ -z "$LOAD_STATUS_MODULE" ]; then |
| 244 |
ocf_run $HTTPD $HTTPDOPTS $OPTIONS -f $CONFIGFILE |
| 245 |
else |
| 246 |
ocf_run $HTTPD -C "$LOAD_STATUS_MODULE" $HTTPDOPTS $OPTIONS -f $CONFIGFILE |
| 247 |
fi |
| 248 |
else |
| 249 |
if [ -z "$LOAD_STATUS_MODULE" ]; then |
| 250 |
ocf_run $HTTPD $HTTPDOPTS $OPTIONS -f $CONFIGFILE -c "PidFile $PidFile" |
| 251 |
else |
| 252 |
ocf_run $HTTPD $HTTPDOPTS -C "$LOAD_STATUS_MODULE" $OPTIONS -f $CONFIGFILE -c "PidFile $PidFile" |
| 253 |
fi |
| 254 |
fi |
| 255 |
|
| 256 |
tries=0 |
| 257 |
while : # wait until the user set timeout |
| 258 |
do |
| 259 |
apache_monitor |
| 260 |
ec=$? |
| 261 |
if [ $ec -eq $OCF_NOT_RUNNING ] |
| 262 |
then |
| 263 |
tries=`expr $tries + 1` |
| 264 |
ocf_log info "waiting for apache $CONFIGFILE to come up" |
| 265 |
sleep 1 |
| 266 |
else |
| 267 |
break |
| 268 |
fi |
| 269 |
done |
| 270 |
|
| 271 |
if [ $ec -ne 0 ] && silent_status; then |
| 272 |
apache_stop |
| 273 |
fi |
| 274 |
return $ec |
| 275 |
} |
| 276 |
|
| 277 |
signal_children() |
| 278 |
{ |
| 279 |
for sig in SIGTERM SIGHUP SIGKILL ; do |
| 280 |
if pgrep -f $HTTPD.*$CONFIGFILE >/dev/null ; then |
| 281 |
pkill -$sig -f $HTTPD.*$CONFIGFILE >/dev/null |
| 282 |
ocf_log info "signal $sig sent to apache children" |
| 283 |
sleep 1 |
| 284 |
else |
| 285 |
break |
| 286 |
fi |
| 287 |
done |
| 288 |
} |
| 289 |
|
| 290 |
graceful_stop() |
| 291 |
{ |
| 292 |
local tries=10 |
| 293 |
local pid=$1 |
| 294 |
|
| 295 |
# Try graceful stop for half timeout period if timeout period is present |
| 296 |
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then |
| 297 |
tries=$((($OCF_RESKEY_CRM_meta_timeout/1000) / 2)) |
| 298 |
fi |
| 299 |
|
| 300 |
ocf_log info "Attempting graceful stop of apache PID $pid" |
| 301 |
kill -WINCH $pid >/dev/null |
| 302 |
while |
| 303 |
ProcessRunning $pid && |
| 304 |
[ $tries -gt 0 ] |
| 305 |
do |
| 306 |
sleep 1 |
| 307 |
tries=`expr $tries - 1` |
| 308 |
done |
| 309 |
|
| 310 |
if [ $tries -eq 0 ]; then |
| 311 |
# graceful stop didn't work, process still up. |
| 312 |
return 1 |
| 313 |
fi |
| 314 |
|
| 315 |
return 0 |
| 316 |
} |
| 317 |
|
| 318 |
kill_stop() |
| 319 |
{ |
| 320 |
local tries=0 |
| 321 |
local pid=$1 |
| 322 |
|
| 323 |
ocf_log info "Killing apache PID $pid" |
| 324 |
if ProcessRunning $pid; then |
| 325 |
kill $pid >/dev/null |
| 326 |
while |
| 327 |
[ $tries -lt 10 ] |
| 328 |
do |
| 329 |
if ProcessRunning $pid; then |
| 330 |
tries=`expr $tries + 1` |
| 331 |
sleep 1 |
| 332 |
else |
| 333 |
break |
| 334 |
fi |
| 335 |
done |
| 336 |
fi |
| 337 |
} |
| 338 |
|
| 339 |
apache_stop() { |
| 340 |
local ret=$OCF_SUCCESS |
| 341 |
local pid |
| 342 |
|
| 343 |
if ! silent_status; then |
| 344 |
ocf_log info "$CMD is not running." |
| 345 |
signal_children |
| 346 |
return $ret |
| 347 |
fi |
| 348 |
|
| 349 |
pid=`get_pid` |
| 350 |
graceful_stop $pid |
| 351 |
if [ $? -ne 0 ]; then |
| 352 |
kill_stop $pid |
| 353 |
fi |
| 354 |
|
| 355 |
signal_children |
| 356 |
|
| 357 |
if ProcessRunning $pid; then |
| 358 |
ocf_exit_reason "$CMD still running ($pid). Killing pid failed." |
| 359 |
ret=$OCF_ERR_GENERIC |
| 360 |
fi |
| 361 |
|
| 362 |
if [ $ret -eq 0 ]; then |
| 363 |
ocf_log info "$CMD stopped." |
| 364 |
fi |
| 365 |
|
| 366 |
return $ret |
| 367 |
} |
| 368 |
|
| 369 |
apache_monitor_10() { |
| 370 |
if [ -f "$TESTCONFFILE" ] && [ -r "$TESTCONFFILE" ]; then |
| 371 |
readtestconf < $TESTCONFFILE |
| 372 |
else |
| 373 |
test_url="$TESTURL" |
| 374 |
test_regex="$TESTREGEX10" |
| 375 |
fi |
| 376 |
|
| 377 |
whattorun=`gethttpclient` |
| 378 |
fixtesturl |
| 379 |
is_testconf_sane || |
| 380 |
return $OCF_ERR_CONFIGURED |
| 381 |
|
| 382 |
if $whattorun "$test_url" | grep -Ei "$test_regex" > /dev/null |
| 383 |
then |
| 384 |
return $OCF_SUCCESS |
| 385 |
else |
| 386 |
if ! ocf_is_probe; then |
| 387 |
ocf_exit_reason "Failed to access httpd status page." |
| 388 |
fi |
| 389 |
return $OCF_ERR_GENERIC |
| 390 |
fi |
| 391 |
} |
| 392 |
|
| 393 |
# If the user has not provided any basic monitoring |
| 394 |
# information, allow the agent to verify the server is |
| 395 |
# healthy and capable of processing requests by requesting |
| 396 |
# the http header of website's index |
| 397 |
attempt_index_monitor_request() { |
| 398 |
local indexpage="" |
| 399 |
|
| 400 |
if [ -n "$OCF_RESKEY_testregex" ]; then |
| 401 |
return 1; |
| 402 |
fi |
| 403 |
if [ -n "$OCF_RESKEY_testregex10" ]; then |
| 404 |
return 1; |
| 405 |
fi |
| 406 |
if [ -n "$OCF_RESKEY_testurl" ]; then |
| 407 |
return 1; |
| 408 |
fi |
| 409 |
if [ -n "$OCF_RESKEY_statusurl" ]; then |
| 410 |
return 1; |
| 411 |
fi |
| 412 |
if [ -n "$OCF_RESKEY_testconffile" ]; then |
| 413 |
return 1; |
| 414 |
fi |
| 415 |
|
| 416 |
indexpage=$(buildlocalurl) |
| 417 |
|
| 418 |
request_url_header $indexpage |
| 419 |
if [ $? -ne 0 ]; then |
| 420 |
return $OCF_ERR_GENERIC |
| 421 |
fi |
| 422 |
ocf_log debug "Successfully retrieved http header at $indexpage" |
| 423 |
return 0 |
| 424 |
} |
| 425 |
|
| 426 |
apache_monitor_basic() { |
| 427 |
if ${ourhttpclient}_func "$STATUSURL" | grep -Ei "$TESTREGEX" > /dev/null |
| 428 |
then |
| 429 |
return $OCF_SUCCESS |
| 430 |
fi |
| 431 |
|
| 432 |
attempt_index_monitor_request |
| 433 |
if [ $? -eq 0 ]; then |
| 434 |
return $OCF_SUCCESS |
| 435 |
fi |
| 436 |
|
| 437 |
if ! ocf_is_probe; then |
| 438 |
ocf_exit_reason "Failed to access httpd status page." |
| 439 |
fi |
| 440 |
return $OCF_ERR_GENERIC |
| 441 |
} |
| 442 |
apache_monitor() { |
| 443 |
silent_status |
| 444 |
if [ $? -ne 0 ]; then |
| 445 |
ocf_log info "$CMD not running" |
| 446 |
return $OCF_NOT_RUNNING |
| 447 |
fi |
| 448 |
|
| 449 |
ourhttpclient=`findhttpclient` # we'll need one |
| 450 |
if [ -z "$ourhttpclient" ]; then |
| 451 |
ocf_exit_reason "could not find a http client; make sure that either wget or curl is available" |
| 452 |
return $OCF_ERR_INSTALLED |
| 453 |
fi |
| 454 |
|
| 455 |
case `ocf_check_level 10` in |
| 456 |
0) apache_monitor_basic;; |
| 457 |
10) apache_monitor_10;; |
| 458 |
esac |
| 459 |
} |
| 460 |
|
| 461 |
detect_default_config() |
| 462 |
{ |
| 463 |
if [ -f $DEFAULT_SUSECONFIG ]; then |
| 464 |
echo $DEFAULT_SUSECONFIG |
| 465 |
elif [ -f $DEFAULT_DEBIANCONFIG ]; then |
| 466 |
echo $DEFAULT_DEBIANCONFIG |
| 467 |
else |
| 468 |
echo $DEFAULT_RHELCONFIG |
| 469 |
fi |
| 470 |
} |
| 471 |
|
| 472 |
|
| 473 |
apache_meta_data(){ |
| 474 |
cat <<END |
| 475 |
<?xml version="1.0"?> |
| 476 |
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> |
| 477 |
<resource-agent name="apache" version="1.0"> |
| 478 |
<version>1.0</version> |
| 479 |
|
| 480 |
<longdesc lang="en"> |
| 481 |
This is the resource agent for the Apache Web server. |
| 482 |
This resource agent operates both version 1.x and version 2.x Apache |
| 483 |
servers. |
| 484 |
|
| 485 |
The start operation ends with a loop in which monitor is |
| 486 |
repeatedly called to make sure that the server started and that |
| 487 |
it is operational. Hence, if the monitor operation does not |
| 488 |
succeed within the start operation timeout, the apache resource |
| 489 |
will end with an error status. |
| 490 |
|
| 491 |
The monitor operation by default loads the server status page |
| 492 |
which depends on the mod_status module and the corresponding |
| 493 |
configuration file (usually /etc/apache2/mod_status.conf). |
| 494 |
Make sure that the server status page works and that the access |
| 495 |
is allowed *only* from localhost (address 127.0.0.1). |
| 496 |
See the statusurl and testregex attributes for more details. |
| 497 |
|
| 498 |
See also http://httpd.apache.org/ |
| 499 |
</longdesc> |
| 500 |
<shortdesc lang="en">Manages an Apache Web server instance</shortdesc> |
| 501 |
|
| 502 |
<parameters> |
| 503 |
<parameter name="configfile" required="0" unique="1"> |
| 504 |
<longdesc lang="en"> |
| 505 |
The full pathname of the Apache configuration file. |
| 506 |
This file is parsed to provide defaults for various other |
| 507 |
resource agent parameters. |
| 508 |
</longdesc> |
| 509 |
<shortdesc lang="en">configuration file path</shortdesc> |
| 510 |
<content type="string" default="$(detect_default_config)" /> |
| 511 |
</parameter> |
| 512 |
|
| 513 |
<parameter name="httpd"> |
| 514 |
<longdesc lang="en"> |
| 515 |
The full pathname of the httpd binary (optional). |
| 516 |
</longdesc> |
| 517 |
<shortdesc lang="en">httpd binary path</shortdesc> |
| 518 |
<content type="string" default="${OCF_RESKEY_httpd_default}" /> |
| 519 |
</parameter> |
| 520 |
|
| 521 |
<parameter name="port" > |
| 522 |
<longdesc lang="en"> |
| 523 |
A port number that we can probe for status information |
| 524 |
using the statusurl. |
| 525 |
This will default to the port number found in the |
| 526 |
configuration file, or 80, if none can be found |
| 527 |
in the configuration file. |
| 528 |
|
| 529 |
</longdesc> |
| 530 |
<shortdesc lang="en">httpd port</shortdesc> |
| 531 |
<content type="integer" /> |
| 532 |
</parameter> |
| 533 |
|
| 534 |
<parameter name="statusurl"> |
| 535 |
<longdesc lang="en"> |
| 536 |
The URL to monitor (the apache server status page by default). |
| 537 |
If left unspecified, it will be inferred from |
| 538 |
the apache configuration file. |
| 539 |
|
| 540 |
If you set this, make sure that it succeeds *only* from the |
| 541 |
localhost (127.0.0.1). Otherwise, it may happen that the cluster |
| 542 |
complains about the resource being active on multiple nodes. |
| 543 |
</longdesc> |
| 544 |
<shortdesc lang="en">url name</shortdesc> |
| 545 |
<content type="string" /> |
| 546 |
</parameter> |
| 547 |
|
| 548 |
<parameter name="testregex"> |
| 549 |
<longdesc lang="en"> |
| 550 |
Regular expression to match in the output of statusurl. |
| 551 |
Case insensitive. |
| 552 |
</longdesc> |
| 553 |
<shortdesc lang="en">monitor regular expression</shortdesc> |
| 554 |
<content type="string" default="exists, but impossible to show in a human readable format (try grep testregex)"/> |
| 555 |
</parameter> |
| 556 |
|
| 557 |
<parameter name="client"> |
| 558 |
<longdesc lang="en"> |
| 559 |
Client to use to query to Apache. If not specified, the RA will |
| 560 |
try to find one on the system. Currently, wget and curl are |
| 561 |
supported. For example, you can set this parameter to "curl" if |
| 562 |
you prefer that to wget. |
| 563 |
</longdesc> |
| 564 |
<shortdesc lang="en">http client</shortdesc> |
| 565 |
<content type="string" default=""/> |
| 566 |
</parameter> |
| 567 |
|
| 568 |
<parameter name="testurl"> |
| 569 |
<longdesc lang="en"> |
| 570 |
URL to test. If it does not start with "http", then it's |
| 571 |
considered to be relative to the Listen address. |
| 572 |
</longdesc> |
| 573 |
<shortdesc lang="en">test url</shortdesc> |
| 574 |
<content type="string" /> |
| 575 |
</parameter> |
| 576 |
|
| 577 |
<parameter name="testregex10"> |
| 578 |
<longdesc lang="en"> |
| 579 |
Regular expression to match in the output of testurl. |
| 580 |
Case insensitive. |
| 581 |
</longdesc> |
| 582 |
<shortdesc lang="en">extended monitor regular expression</shortdesc> |
| 583 |
<content type="string" /> |
| 584 |
</parameter> |
| 585 |
|
| 586 |
<parameter name="testconffile"> |
| 587 |
<longdesc lang="en"> |
| 588 |
A file which contains test configuration. Could be useful if |
| 589 |
you have to check more than one web application or in case sensitive |
| 590 |
info should be passed as arguments (passwords). Furthermore, |
| 591 |
using a config file is the only way to specify certain |
| 592 |
parameters. |
| 593 |
|
| 594 |
Please see README.webapps for examples and file description. |
| 595 |
</longdesc> |
| 596 |
<shortdesc lang="en">test configuration file</shortdesc> |
| 597 |
<content type="string" /> |
| 598 |
</parameter> |
| 599 |
|
| 600 |
<parameter name="testname"> |
| 601 |
<longdesc lang="en"> |
| 602 |
Name of the test within the test configuration file. |
| 603 |
</longdesc> |
| 604 |
<shortdesc lang="en">test name</shortdesc> |
| 605 |
<content type="string" /> |
| 606 |
</parameter> |
| 607 |
|
| 608 |
<parameter name="options"> |
| 609 |
<longdesc lang="en"> |
| 610 |
Extra options to apply when starting apache. See man httpd(8). |
| 611 |
</longdesc> |
| 612 |
<shortdesc lang="en">command line options</shortdesc> |
| 613 |
<content type="string" /> |
| 614 |
</parameter> |
| 615 |
|
| 616 |
<parameter name="envfiles"> |
| 617 |
<longdesc lang="en"> |
| 618 |
Files (one or more) which contain extra environment variables. |
| 619 |
If you want to prevent script from reading the default file, set |
| 620 |
this parameter to empty string. |
| 621 |
</longdesc> |
| 622 |
<shortdesc lang="en">environment settings files</shortdesc> |
| 623 |
<content type="string" default="${OCF_RESKEY_envfiles_default}"/> |
| 624 |
</parameter> |
| 625 |
|
| 626 |
<parameter name="use_ipv6"> |
| 627 |
<longdesc lang="en"> |
| 628 |
We will try to detect if the URL (for monitor) is IPv6, but if |
| 629 |
that doesn't work set this to true to enforce IPv6. |
| 630 |
</longdesc> |
| 631 |
<shortdesc lang="en">use ipv6 with http clients</shortdesc> |
| 632 |
<content type="boolean" default="${OCF_RESKEY_use_ipv6_default}"/> |
| 633 |
</parameter> |
| 634 |
|
| 635 |
</parameters> |
| 636 |
|
| 637 |
<actions> |
| 638 |
<action name="start" timeout="40s" /> |
| 639 |
<action name="stop" timeout="60s" /> |
| 640 |
<action name="status" timeout="30s" /> |
| 641 |
<action name="monitor" depth="0" timeout="20s" interval="10s" /> |
| 642 |
<action name="meta-data" timeout="5s" /> |
| 643 |
<action name="validate-all" timeout="5s" /> |
| 644 |
</actions> |
| 645 |
</resource-agent> |
| 646 |
END |
| 647 |
return $OCF_SUCCESS |
| 648 |
} |
| 649 |
|
| 650 |
apache_validate_all() { |
| 651 |
if [ -z "$HTTPD" ]; then |
| 652 |
ocf_exit_reason "apache httpd program not found" |
| 653 |
return $OCF_ERR_INSTALLED |
| 654 |
fi |
| 655 |
if [ ! -x "$HTTPD" ]; then |
| 656 |
ocf_exit_reason "HTTPD $HTTPD not found or is not an executable!" |
| 657 |
return $OCF_ERR_INSTALLED |
| 658 |
fi |
| 659 |
if [ ! -f $CONFIGFILE ]; then |
| 660 |
ocf_exit_reason "Configuration file $CONFIGFILE not found!" |
| 661 |
return $OCF_ERR_INSTALLED |
| 662 |
fi |
| 663 |
|
| 664 |
# validate testconffile/testurl before apache_monitor_10() |
| 665 |
if [ -n "$TESTCONFFILE" ]; then |
| 666 |
if [ ! -f "$TESTCONFFILE" ] || [ ! -r "$TESTCONFFILE" ]; then |
| 667 |
ocf_exit_reason "Configuration file $TESTCONFFILE not found, or not readable." |
| 668 |
return $OCF_ERR_INSTALLED |
| 669 |
fi |
| 670 |
else |
| 671 |
if [ -n "$TESTURL" ]; then |
| 672 |
# remove leading or trailing spaces/tabs |
| 673 |
local temp=$(printf "$TESTURL" | sed -e 's/^[ \t]*//g' -e 's/[ \t]*$//g') |
| 674 |
|
| 675 |
if [ -z "$temp" ]; then |
| 676 |
ocf_exit_reason "testurl: \"$TESTURL\" seems to be an empty string?" |
| 677 |
return $OCF_ERR_CONFIGURED |
| 678 |
fi |
| 679 |
fi |
| 680 |
|
| 681 |
# FIXME: validate TESTREGEX10 will be needed if empty regex is not allow. |
| 682 |
fi |
| 683 |
|
| 684 |
ocf_mkstatedir root 755 `dirname $PidFile` || return $OCF_ERR_INSTALLED |
| 685 |
return $OCF_SUCCESS |
| 686 |
} |
| 687 |
|
| 688 |
find_httpd_prog() { |
| 689 |
case $0 in |
| 690 |
*IBM*) |
| 691 |
HTTPD=$IBMHTTPD |
| 692 |
DefaultConfig=$DEFAULT_IBMCONFIG;; |
| 693 |
*) |
| 694 |
HTTPD= |
| 695 |
for h in $HTTPDLIST |
| 696 |
do |
| 697 |
if [ -f $h -a -x $h ]; then |
| 698 |
HTTPD=$h |
| 699 |
break |
| 700 |
fi |
| 701 |
done |
| 702 |
|
| 703 |
# Let the user know that the $HTTPD used is not the one (s)he specified via $OCF_RESKEY_httpd |
| 704 |
if [ "X$OCF_RESKEY_httpd" != X -a "X$HTTPD" != X ]; then |
| 705 |
ocf_log info "Using $HTTPD as HTTPD" |
| 706 |
fi |
| 707 |
DefaultConfig=$(detect_default_config) |
| 708 |
;; |
| 709 |
esac |
| 710 |
} |
| 711 |
|
| 712 |
apache_getconfig() { |
| 713 |
# these variables are global |
| 714 |
HTTPD="$OCF_RESKEY_httpd" |
| 715 |
PORT="$OCF_RESKEY_port" |
| 716 |
STATUSURL="$OCF_RESKEY_statusurl" |
| 717 |
CONFIGFILE="$OCF_RESKEY_configfile" |
| 718 |
OPTIONS="$OCF_RESKEY_options" |
| 719 |
CLIENT=${OCF_RESKEY_client} |
| 720 |
TESTREGEX=${OCF_RESKEY_testregex:-'</ *html *>'} |
| 721 |
TESTURL="$OCF_RESKEY_testurl" |
| 722 |
TESTREGEX10=${OCF_RESKEY_testregex10} |
| 723 |
TESTCONFFILE="$OCF_RESKEY_testconffile" |
| 724 |
TESTNAME="$OCF_RESKEY_testname" |
| 725 |
: ${OCF_RESKEY_envfiles=${OCF_RESKEY_envfiles_default}} |
| 726 |
source_envfiles $OCF_RESKEY_envfiles |
| 727 |
|
| 728 |
if [ "X$HTTPD" = X -o ! -f "$HTTPD" -o ! -x "$HTTPD" ]; then |
| 729 |
find_httpd_prog |
| 730 |
fi |
| 731 |
|
| 732 |
CONFIGFILE=${CONFIGFILE:-$DefaultConfig} |
| 733 |
if [ -n "$HTTPD" ]; then |
| 734 |
httpd_basename=`basename $HTTPD` |
| 735 |
case $httpd_basename in |
| 736 |
*-*) httpd_basename=`echo "$httpd_basename" | sed -e 's%\-.*%%'`;; |
| 737 |
esac |
| 738 |
fi |
| 739 |
GetParams $CONFIGFILE |
| 740 |
} |
| 741 |
|
| 742 |
OCF_REQUIRED_PARAMS="" |
| 743 |
OCF_REQUIRED_BINARIES="" |
| 744 |
ocf_rarun $* |