Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/heartbeat/WAS.in b/heartbeat/WAS.in
index a5f81b0e0..e009283d8 100644
--- a/heartbeat/WAS.in
+++ b/heartbeat/WAS.in
@@ -1,611 +1,602 @@
#!/bin/sh
#
-# $Id: WAS.in,v 1.8 2006/01/26 18:00:05 lars Exp $
+# $Id: WAS.in,v 1.9 2006/02/11 14:31:14 xunsun Exp $
#
# WAS
#
# Description: Manages a Websphere Application Server as an HA resource
#
#
# Author: Alan Robertson
# Support: linux-ha@lists.linux-ha.org
# License: GNU General Public License (GPL)
# Copyright: (C) 2002 - 2005 International Business Machines, Inc.
#
#
# An example usage in /etc/ha.d/haresources:
# node1 10.0.0.170 WAS::/opt/WebSphere/ApplicationServer/config/server-cfg.xml
#
# See usage() function below for more details...
#
# OCF parameters are as below:
# OCF_RESKEY_config
# (WAS-configuration file, used for the single server edition of WAS)
# OCF_RESKEY_port
# (WAS-<snoop>-port-number, used for the advanced edition of WAS)
#######################################################################
# Initialization:
. @hb_libdir@/ocf-shellfuncs
#######################################################################
WASDIR=/opt/WebSphere/AppServer
if
[ ! -d $WASDIR ]
then
WASDIR=/usr/WebSphere/AppServer
fi
STARTTIME=300 # 5 minutes
WGET=/usr/bin/wget
DEFAULT_WASPORTS="9080"
#
#
WASBIN=$WASDIR/bin
DEFAULT=$WASDIR/config/server-cfg.xml
#
# Print usage message
#
usage() {
methods=`WAS_methods | grep -v methods`
methods=`echo $methods | tr ' ' '|'`
cat <<-!
usage: $0 ($methods)
For the single server edition of WAS, you have to set the following
enviroment virable:
OCF_RESKEY_config
(WAS-configuration file)
For the advanced edition of WAS, you have to set the following
enviroment virable:
OCF_RESKEY_port
(WAS-<snoop>-port-number)
$0 manages a Websphere Application Server (WAS) as an HA resource
The 'start' operation starts WAS.
The 'stop' operation stops WAS.
The 'status' operation reports whether WAS is running
The 'monitor' operation reports whether the WAS seems to be working
(httpd also needs to be working for this case)
The 'validate-all' operation reports whether the OCF instance parameter (OCF_RESKEY_config or OCF_RESKEY_port) is valid
The 'methods' operation reports on the methods $0 supports
This is known to work with the Single Server edition of Websphere,
and is believed to work with the Advanced edition too.
Since the Advanced Edition has no configuration file (it's in a the
database) you need to give a port number instead of a
configuration file for this config parameter.
The default configuration file for the single server edition is:
$DEFAULT
The default snoop-port for the advanced edition is: $DEFAULT_WASPORTS
The start and stop operations must be run as root.
The status operation will report a pid of "-" for the
WAS root process using unless it is run as root.
If you don't have xmllint on your system, parsing of WAS
configuration files is very primitive.
In this case, the port specification we need from the XML
config file has to be on the same line as the
first part of the <transports/> tag.
We run servlet/snoop on the first transport port listed in
the config file for the "monitor" operation.
- $Id: WAS.in,v 1.8 2006/01/26 18:00:05 lars Exp $
+ $Id: WAS.in,v 1.9 2006/02/11 14:31:14 xunsun Exp $
!
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="WAS">
<version>1.0</version>
<longdesc lang="en">
Resource script for WAS. It manages a Websphere Application Server (WAS) as
an HA resource.
</longdesc>
<shortdesc lang="en">WAS resource agent</shortdesc>
<parameters>
<parameter name="config" unique="0" required="1">
<longdesc lang="en">
The WAS-configuration file.
</longdesc>
<shortdesc lang="en">configration file</shortdesc>
<content type="string" default="$DEFAULT" />
</parameter>
<parameter name="port" unique="0">
<longdesc lang="en">
The WAS-(snoop)-port-number.
</longdesc>
<shortdesc lang="en">port</shortdesc>
<content type="integer" default="$DEFAULT_WASPORTS" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="300" />
<action name="stop" timeout="300" />
<action name="status" depth="0" timeout="30" interval="10" start-delay="10" />
<action name="monitor" depth="0" timeout="30" interval="10" start-delay="10" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
<action name="methods" timeout="5" />
</actions>
</resource-agent>
END
}
#
# Run: Run a script, and log its output.
#
run() {
output=`"$@" 2>&1`
rc=$?
output=`echo $output`
if
[ $rc -eq 0 ]
then
if
[ ! -z "$output" ]
then
ocf_log info "$output"
fi
return 0
else
if
[ ! -z "$output" ]
then
ocf_log "err" "$output"
else
ocf_log "err" "command failed: $*"
fi
return $rc
fi
}
#
# Reformat the XML document in a sort of canonical form
# if we can. If we don't have xmllint, we just cat it out
# and hope for the best ;-)
#
xmlcat() {
if
[ "X$XMLcat" = X ]
then
XMLcat=`which xmllint 2>/dev/null`
if
[ "X${XMLcat}" = X -o ! -x "${XMLcat}" ]
then
XMLcat=cat
else
XMLcat="$XMLcat --recover --format"
fi
fi
for j in "$@"
do
${XMLcat} "$j"
done
}
#
#This is a bit skanky, but it works anyway...
#
#<transports xmi:type="applicationserver:HTTPTransport" xmi:id="HttpTransport_1" hostname="*" port="9080"/>
#<transports xmi:type="applicationserver:HTTPTransport" xmi:id="HttpTransport_2" hostname="*" port="9443" sslEnabled="true"/>
#<transports xmi:type="applicationserver:HTTPTransport" xmi:id="HttpTransport_3" hostname="*" port="9090" external="false"/>
#
# It's not really skanky if we can find xmllint on the system, because it
# reformats tags so they are all on one line, which is all we we need...
#
#
# Get the numbers of the ports WAS should be listening on...
#
# If we don't have xmllint around, then the applicationserver and the
# port= specification have to be on the same line in the XML config file.
#
GetWASPorts() {
case $1 in
[0-9]*) echo "$1" | tr ',' '\012';;
*)
xmlcat $1 | grep -i 'transports.*applicationserver:HTTPTransport' |
grep port= |
sed -e 's%.*port= *"* *%%' \
-e 's%[^0-9][^0-9]*.*$%%'
# Delete up to port=, throw away optional quote and optional
# white space.
# Throw away everything after the first non-digit.
# This should leave us the port number all by itself...
esac
}
#
# We assume that the first port listed in the <transports/>
# is the one we should run servlet/snoop on.
#
GetWASSnoopPort() {
GetWASPorts "$@" | head -n1
}
#
# Return information on the processname/id for the WAS ports
#
# pid/java is the expected output. Several lines, one per port...
#
#
WASPortInfo() {
pat=""
once=yes
PortCount=0
for j in $*
do
case $pat in
"") pat="$j";;
*) pat="$pat|$j";;
esac
PortCount=`expr $PortCount + 1`
done
netstat -ltnp 2>/dev/null| egrep -i "($pat) .*LISTEN" | sed 's%.*LISTEN *%%'
}
#
# Return the number of WAS ports which are open
#
CheckWASPortsInUse() {
count=`WASPortInfo "$@" | wc -l`
echo $count
}
#
# Return the pid(s) of the processes that have WAS ports open
#
WASPIDs() {
WASPortInfo "$@" | sort -u | cut -f1 -d/
}
#
# The version of ps that returns all processes and their (long) args
# It's only used by WAS_procs, which isn't used for anything ;-)
#
ps_long() {
ps axww
}
#
# The total set of WAS processes (single server only)
#
WAS_procs() {
ps_long | grep -i "config=$1" | grep -i java | cut -d' ' -f1
}
#
# methods: What methods/operations do we support?
#
WAS_methods() {
cat <<-!
start
stop
status
methods
validate-all
meta-data
usage
!
if
[ -f $WGET -a -x $WGET ]
then
echo monitor
fi
}
#
# Return WAS status (silently)
#
WAS_status() {
WASPorts=`GetWASPorts $1`
PortsInUse=`CheckWASPortsInUse $WASPorts`
case $PortsInUse in
0) false;;
*) true;;
esac
}
#
# Report on WAS status to stdout...
#
WAS_report_status() {
WASPorts=`GetWASPorts $1`
PortCount=`echo $WASPorts | wc -w`
PortCount=`echo $PortCount`
PortsInUse=`CheckWASPortsInUse $WASPorts`
case $PortsInUse in
0) ocf_log debug "WAS: server $1 is stopped."; return $OCF_NOT_RUNNING;;
*)
pids=`WASPIDs $WASPorts`
if
[ $PortsInUse -ge $PortCount ]
then
ocf_log debug "WAS: server $1 is running (pid" $pids "et al)."
else
ocf_log debug "WAS: server $1 is running (pid $pids et al) but not listening on all ports."
fi
return $OCF_SUCCESS;;
esac
}
#
# Monitor WAS - does it really seem to be working?
#
# For this we invoke the snoop applet via wget.
#
# This is actually faster than WAS_status above...
#
WAS_monitor() {
tmpfile=`maketempfile`
SnoopPort=`GetWASSnoopPort $1`
output=`$WGET -nv -O$tmpfile http://localhost:$SnoopPort/servlet/snoop 2>&1`
rc=$?
if
[ $rc -eq 0 ]
then
if
grep -i 'user-agent.*Wget' $tmpfile >/dev/null
then
: OK
else
ocf_log "err" "WAS: $1: no user-agent from snoop application"
rc=$OCF_ERR_GENERIC
fi
else
ocf_log "err" "WAS: $1: wget failure: $output"
rc=$OCF_ERR_GENERIC
fi
rm -fr $tmpfile
return $rc
}
#
# Start WAS instance
#
WAS_start() {
# Launch Arguments:
#
# -configFile <configFile>
# -nodeName <nodeName>
# -serverName <serverName>
# -oltEnabled
# -oltHost <hostname>
# -oltPort <port>
# -debugEnabled
# -jdwpPort <port>
# -debugSource <sourcePath>
# -serverTrace <traceString>
# -serverTraceFile <traceFile>
# -script [<scriptFile>]
# -platform <platformName>
# -noExecute
# -help
if
[ -x $WASBIN/startServer.sh ]
then
cmd="$WASBIN/startServer.sh -configFile $1"
else
cmd="$WASBIN/startupServer.sh"
fi
if
run $cmd
then
if
WAS_wait_4_start $STARTTIME "$@"
then
#true
return $OCF_SUCCESS
else
ocf_log "err" "WAS server $1 did not start correctly"
return $OCF_ERR_GENERIC
fi
else
#false
return $OCF_ERR_GENERIC
fi
}
#
# Wait for WAS to actually start up.
#
# It seems to take between 30 and 60 seconds for it to
# start up on a trivial WAS instance.
#
WAS_wait_4_start() {
max=$1
retries=0
shift
while
[ $retries -lt $max ]
do
if
WAS_status "$@"
then
return $OCF_SUCCESS
else
sleep 1
fi
retries=`expr $retries + 1`
done
WAS_status "$@"
}
#
# Shut down WAS
#
WAS_stop() {
# They don't return good return codes...
# And, they seem to allow anyone to stop WAS (!)
if
[ -x $WASBIN/stopServer.sh ]
then
run $WASBIN/stopServer.sh -configFile $1
else
WASPorts=`GetWASPorts $1`
kill `WASPIDs $WASPorts`
fi
if
WAS_status $1
then
ocf_log "err" "WAS: $1 did not stop correctly"
#false
return $OCF_ERR_GENERIC
else
#true
return $OCF_SUCCESS
fi
}
#
-# Check if the port is valid, this function code is not decent, but works
+# Check if the port is valid
#
CheckPort() {
-# Examples of valid port: "1080", "1", "0080"
-# Examples of invalid port: "1080bad", "0", "0000", ""
- case "$1" in
- *[^0-9]*) #got invalid char
- false;;
- *[1-9]*) #no invalid char, and has non-zero digit, so is a good port
- true;;
- *) #empty string, or string of 0's
- false;;
- esac
+ ocf_is_decimal "$1" && [ $1 -gt 0 ]
}
WAS_validate_all() {
if [ -x $WASBIN/startServer.sh ]; then
# $arg should be config file
if [ ! -f "$arg" ]; then
ocf_log err "Configuration file [$arg] does not exist"
exit $OCF_ERR_ARGS
fi
# $arg should specify a valid port number at the very least
local WASPorts=`GetWASPorts $arg`
if [ -z "$WASPorts" ]; then
ocf_log err "No port number specified in configuration file [$arg]"
exit $OCF_ERR_CONFIGURED
fi
local port
local have_valid_port=false
for port in "$WASPorts"; do
if CheckPort $port; then
have_valid_port=true
break
fi
done
if [ "false" = "$have_valid_port" ]; then
ocf_log err "No valid port number specified in configuration file [$arg]"
exit $OCF_ERR_CONFIGURED
fi
elif [ -x $WASBIN/startupServer.sh ]; then
# $arg should be port number
if CheckPort "$arg"; then
ocf_log err "Port number is required but [$arg] is not valid port number"
exit $OCF_ERR_ARGS
fi
else
# Do not know hot to validate_all
ocf_log warn "Do not know how to validate-all, assuming validation OK"
return $OCF_SUCCESS
fi
}
#
# 'main' starts here...
#
if
( [ $# -ne 1 ] )
then
usage
exit $OCF_ERR_ARGS
fi
#
# Supply default configuration parameter(s)
#
if
( [ -z $OCF_RESKEY_config ] && [ -z $OCF_RESKEY_port ] )
then
if
[ -f $DEFAULT ]
then
arg=$DEFAULT
else
arg=$DEFAULT_WASPORTS
fi
elif
[ ! -z $OCF_RESKEY_config ]
then
arg=$OCF_RESKEY_config
else
arg=$OCF_RESKEY_port
fi
if
[ ! -f $arg ]
then
case $arg in
[0-9]*) ;; # ignore port numbers...
*) ocf_log "err" "WAS configuration file $arg does not exist!"
usage
exit $OCF_ERR_ARGS;;
esac
fi
# What kind of method was invoked?
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
start) WAS_start $arg
exit $?;;
stop) WAS_stop $arg
exit $?;;
status) WAS_report_status $arg
exit $?;;
monitor) WAS_monitor $arg
exit $?;;
validate-all) WAS_validate_all $arg
exit $?;;
methods) WAS_methods
exit $?;;
usage) usage
exit $OCF_SUCCESS;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac
diff --git a/heartbeat/apache.in b/heartbeat/apache.in
index 772bc16ff..9d467d447 100644
--- a/heartbeat/apache.in
+++ b/heartbeat/apache.in
@@ -1,601 +1,592 @@
#!/bin/sh
#
# High-Availability Apache/IBMhttp control script
#
# apache (aka IBMhttpd)
#
# Description: starts/stops apache web servers.
#
# Author: Alan Robertson
# Sun Jiang Dong
#
# Support: linux-ha@lists.linux-ha.org
#
# License: GNU General Public License (GPL)
#
# Copyright: (C) 2002-2005 International Business Machines
#
#
# An example usage in /etc/ha.d/haresources:
# node1 10.0.0.170 apache::/opt/IBMHTTPServer/conf/httpd.conf
# node1 10.0.0.170 IBMhttpd
#
# Our parsing of the Apache config files is very rudimentary.
# It'll work with lots of different configurations - but not every
# possible configuration.
#
# Patches are being accepted ;-)
#
# OCF parameters:
# OCF_RESKEY_configfile
# OCF_RESKEY_httpd
# OCF_RESKEY_port
# OCF_RESKEY_statusurl
VARRUN=@localstatedir@/run
. @hb_libdir@/ocf-shellfuncs
#######################################################################
#
# Configuration options - usually you don't need to change these
#
#######################################################################
#
IBMHTTPD=/opt/IBMHTTPServer/bin/httpd
HTTPDLIST="/sbin/httpd2 /usr/sbin/httpd2 /sbin/httpd /usr/sbin/httpd $IBMHTTPD"
MPM=/usr/share/apache2/find_mpm
if
[ -x $MPM ]
then
HTTPDLIST="$HTTPDLIST `$MPM 2>/dev/null`"
fi
WGETNAME=wget
WGETOPTS="-O- -nv"
LOCALHOST="http://localhost"
HTTPDOPTS="-DSTATUS"
DEFAULT_IBMCONFIG=/opt/IBMHTTPServer/conf/httpd.conf
DEFAULT_NORMCONFIG="/etc/apache2/httpd.conf"
#
# You can also set
# HTTPD
# PORT
# STATUSURL
# CONFIGFILE
# in this section if what we're doing doesn't work for you...
#
# End of Configuration options
#######################################################################
CMD=`basename $0`
# The config-file-pathname is the pathname to the configuration
# file for this web server. Various appropriate defaults are
# assumed if no config file is specified. If this command is
# invoked as *IBM*, then the default config file name is
# $DEFAULT_IBMCONFIG, otherwise the default config file
# will be $DEFAULT_NORMCONFIG.
usage() {
cat <<-!
usage: $0 action
action:
start start the web server
stop stop the web server
status return the status of web server, run or down
monitor return TRUE if the web server appears to be working.
For this to be supported you must configure mod_status
and give it a server-status URL. You have to have
installed $WGETNAME for this to work.
meta-data show meta data message
validate-all validate the instance parameters
!
exit $OCF_ERR_ARGS
}
IncludeLine() {
file=`echo "$1" | sed -e 's%Include *%%' -e 's%[ ]*$%%'`
ExpandMe $file
}
ExpandMe() {
out=/tmp/$$.out
for file in "$@"
do
if
[ ! -f $file ]
then
continue
fi
while read line
do
case $line in
"Include "*) IncludeLine "$line";;
*) echo "$line";;
esac
done < "$file"
done
}
#
# Run: Run a script, and log its output.
#
run() {
output=`"$@" 2>&1`
rc=$?
output=`echo $output`
if
[ $rc -eq 0 ]
then
if
[ ! -z "$output" ]
then
ocf_log info "$output"
fi
return $OCF_SUCCESS
else
if
[ ! -z "$output" ]
then
ocf_log err "$output"
else
ocf_log err "command failed: $*"
fi
return $OCF_ERR_GENERIC
fi
}
#
# Strip comments, and initial blanks. Compress other blanks. Delete lines of blanks only.
#
apachecat() {
ExpandMe "$@" |
sed -e 's%#.*%%' -e '/^[ ]*$/d' -e 's%^[ ]*%%' -e 's%[ ]+% %g'
}
#
# Return the value of a parameter in our apache config file
#
apache_param() {
configfile=$1
varname=$2
if
apachecat $1 | grep -i "^$varname " | \
sed -e 's%^[^ ]* %%' -e 's%^"%%' -e 's%"$%%' -e 's%^[[:blank:]]*%%' -e 's%[[:blank:]]*$%%'
then
: OK
else
false
fi
}
#
# Return TRUE if the config file supports the given handler somewhere
#
SupportsHandler() {
apache_param "$1" SetHandler | grep "^ *$2 *" >/dev/null
}
#
# return true if the given module is loaded...
#
Module_loaded() {
apache_param "$1" AddModule | grep -i "^mod_$2\." >/dev/null
if
[ $? = 0 ]
then
true
else
apache_param "$1" LoadModule | grep -i "mod_$2\." >/dev/null
fi
}
#
# Return the location(s) that are handled by the given handler
#
FindLocationForHandler() {
PerlScript='while (<>) {
/<Location "?([^ >"]+)/i && ($loc=$1);
'"/SetHandler +$2"'/i && print "$loc\n";
}'
apachecat $1 | perl -e "$PerlScript"
}
#
-# Check if the port is valid, this function code is not decent, but works
+# Check if the port is valid
#
CheckPort() {
-# Examples of valid port: "1080", "1", "0080"
-# Examples of invalid port: "1080bad", "0", "0000", ""
- case "$1" in
- *[^0-9]*) #got invalid char
- false;;
- *[1-9]*) #no invalid char, and has non-zero digit, so is a good port
- true;;
- *) #empty string, or string of 0's
- false;;
- esac
+ ocf_is_decimal "$1" && [ $1 -gt 0 ]
}
#
# Get all the parameters we need from the Apache config file
#
GetParams() {
ConfigFile=$1
ServerRoot=`apache_param "$ConfigFile" ServerRoot`
PidFile=`apache_param "$ConfigFile" PidFile`
case $PidFile in
/*) ;;
[[:alnum:]]*) PidFile=$ServerRoot/$PidFile;;
*) PidFile=$VARRUN/${httpd_basename}.pid;;
esac
# case "$PORT" in
# [0-9]*) ;;
# *) PORT=`apache_param "$ConfigFile" Port`
# case "$PORT" in
# [0-9]*) ;;
# *) PORT=80;;
# esac;;
# *)
# esac
if CheckPort "$PORT"; then
:
else
PORT=`apache_param "$ConfigFile" Port`
if CheckPort "$PORT"; then
:
else
# Final resort
PORT=80
fi
fi
if
WGET=`which $WGETNAME 2>/dev/null`
then
: OK
else
WGET=""
fi
#
# Just because they have mod_status loaded and have a server-status
# declared doesn't mean they support the status operation.
#
# It's actually pretty hard to tell because of run-time defines which
# could be turned on elsewhere...
#
# (we start our server with -DSTATUS - just in case :-))
#
# Typically (but not necessarily) the status URL is /server-status
#
# For us to think status will work, we have to have the following things:
#
# - $WGET has to exist and be executable
# - The mod_status module must be loaded
# - The server-status handler has to be mapped to some URL somewhere
#
# We assume that:
#
# - the "main" web server at $PORT will also support it if we can find it
# somewhere in the file
# - it will be supported at the same URL as the one we find in the file
#
# If this doesn't work for you, then set STATUSURL at the top of the file
#
HasStatus=no
if
# && Module_loaded $ConfigFile status
[ ! -z "$WGET" -a -x "$WGET" ] \
&& SupportsHandler $ConfigFile server-status
then
StatusURL=`FindLocationForHandler $1 server-status | tail -1`
case "$StatusURL" in
/*) HasStatus=yes;;
esac
if
[ "X$STATUSURL" = "X" ]
then
STATUSURL="${LOCALHOST}:${PORT}$StatusURL"
fi
fi
if
[ -z "$PidFile" -o ! -f $ConfigFile ]
then
false
else
true
fi
}
#
# return TRUE if a process with given PID is running
#
ProcessRunning() {
ApachePID=$1
# Use /proc if it looks like it's here...
if
[ -d /proc -a -d /proc/1 ]
then
[ -d /proc/$ApachePID ]
else
# This assumes we're running as root...
kill -0 "$ApachePID" >/dev/null 2>&1
fi
}
silent_status() {
if
[ -f $PidFile ]
then
ProcessRunning `cat $PidFile`
else
: No pid file
false
fi
}
start_apache() {
if
silent_status
then
ocf_log info "$CMD already running (pid $ApachePID)"
return $OCF_SUCCESS
fi
run $HTTPD $HTTPDOPTS -f $CONFIGFILE
}
stop_apache() {
if
silent_status
then
if
kill $ApachePID
then
tries=0
while
ProcessRunning $ApachePID &&
[ $tries -lt 10 ]
do
sleep 1
kill $ApachePID >/dev/null 2>&1
ocf_log info "Killing apache PID $ApachePID"
tries=`expr $tries + 1`
done
else
ocf_log warn "Killing apache PID $ApachePID FAILED."
fi
if
ProcessRunning $ApachePID
then
ocf_log info "$CMD still running ($ApachePID)."
false
else
ocf_log info "$CMD stopped."
fi
else
ocf_log info "$CMD is not running."
fi
}
status_apache() {
silent_status
rc=$?
if
[ $rc -eq 0 ]
then
ocf_log info "$CMD is running (pid $ApachePID)."
return $OCF_SUCCESS
else
ocf_log info "$CMD is stopped."
return $OCF_NOT_RUNNING
fi
}
monitor_apache() {
case $HasStatus in
no) ocf_log err "Monitoring not supported by $CONFIGFILE"
return $OCF_ERR_CONFIGURED;;
esac
if
silent_status
then
run sh -c "$WGET $WGETOPTS $STATUSURL | grep -i '</ *body *></ *html *>' >/dev/null"
else
ocf_log err "$CMD not running"
return $OCF_ERR_GENERIC;
fi
}
metadata_apache(){
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="apache">
<version>1.0</version>
<longdesc lang="en">
starts/stops apache web servers.
</longdesc>
<shortdesc lang="en">starts/stops apache web servers.</shortdesc>
<parameters>
<parameter name="configfile" required="1">
<longdesc lang="en">
The fullpath name of configure file.It's a string of path
name. Other parameters can contain in this file.
</longdesc>
<shortdesc lang="en">configure file path</shortdesc>
<content type="string" default="/etc/httpd/httpd.conf" />
</parameter>
<parameter name="httpd">
<longdesc lang="en">
The fullpath name of the executable binary httpd.It's a string of path
name. It's optional.
</longdesc>
<shortdesc lang="en">httpd executable binary path</shortdesc>
<content type="string" default="/usr/sbin/httpd" />
</parameter>
<parameter name="port" unique="1">
<longdesc lang="en">
The number of port, on that port apache instance provide service.
It's a string of number. Also can get from file.
the "main" web server at $PORT will also support it if we can find it
somewhere in the file.
it will be supported at the same URL as the one we find in the file
</longdesc>
<shortdesc lang="en">apache port number</shortdesc>
<content type="string" default="80"/>
</parameter>
<parameter name="statusurl" unique="2">
<longdesc lang="en">
The url of the apache instance. It's a string.
Also can get from file.
</longdesc>
<shortdesc lang="en">url name</shortdesc>
<content type="integer" default=""/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="90" />
<action name="stop" timeout="100" />
<action name="status" timeout="30" />
<action name="monitor" depth="0" timeout="20" interval="10" start-delay="1m" />
<action name="meta-data" timeout="5" />
<action name="validate-all" timeout="5" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
validate_all_apache() {
if [ ! -f $CONFIGFILE ]; then
# We are sure to succeed here, since we have parsed $CONFIGFILE before getting here
ocf_log err "Configuration file $CONFIGFILE not found!"
exit $OCF_ERR_ARGS
fi
if [ ! -x $HTTPD ]; then
ocf_log err "HTTPD $HTTPD not found or is not an executable!"
exit $OCF_ERR_ARGS
fi
if CheckPort $PORT; then
# We are sure to succeed here, since we forced $PORT to be valid in GetParams()
: OK
else
ocf_log err "Port number $PORT is invalid!"
exit $OCF_ERR_ARGS
fi
if [ -z $STATUSURL ]; then
: OK to be empty
else
case $STATUSURL in
http://*/*.*) ;;
*)
ocf_log err "Invalid STATUSURL $STATUSURL"
exit $OCF_ERR_ARGS ;;
esac
fi
return $OCF_SUCCESS
}
if
[ $# -eq 1 ]
then
COMMAND=$1
HTTPD="$OCF_RESKEY_httpd"
PORT="$OCF_RESKEY_port"
STATUSURL="$OCF_RESKEY_statusurl"
CONFIGFILE="$OCF_RESKEY_configfile"
else
usage
fi
if
[ "X$HTTPD" = X -o ! -f "$HTTPD" -o ! -x "$HTTPD" ]
then
case $0 in
*IBM*) HTTPD=$IBMHTTPD
DefaultConfig=$DEFAULT_IBMCONFIG;;
*)
HTTPD=
for h in $HTTPDLIST
do
if
[ -f $h -a -x $h ]
then
HTTPD=$h
break
fi
done
# It is possible that we still do not have a valid httpd at this stage
if [ -z $HTTPD ]; then
ocf_log err "No valid httpd found! Please revise your <HTTPDLIST> item"
exit $OCF_ERR_ARGS
fi
# Let the user know that the $HTTPD used is not the one (s)he specified via $OCF_RESKEY_httpd
if
[ "X$OCF_RESKEY_httpd" != X ]
then
ocf_log info "Using $HTTPD as HTTPD"
fi
DefaultConfig=$DEFAULT_NORMCONFIG;;
esac
fi
httpd_basename=`basename $HTTPD`
case $httpd_basename in
*-*) httpd_basename=`echo "$httpd_basename" | sed -e 's%\-.*%%'`;;
esac
case "$CONFIGFILE" in
"") CONFIGFILE=$DefaultConfig;;
*) ;;
esac
if
[ ! -f "$CONFIGFILE" -a "X$COMMAND" = Xstop ]
then
ocf_log warn "$CONFIGFILE not found - apache considered stopped"
exit $OCF_SUCCESS
fi
if
GetParams $CONFIGFILE
then
: OK
else
ocf_log err "Cannot parse config file [$CONFIGFILE]"
exit $OCF_ERR_ARGS
fi
case $COMMAND in
start) start_apache;;
stop) stop_apache;;
status) status_apache;;
monitor) monitor_apache;;
meta-data) metadata_apache;;
validate-all) validate_all_apache;;
*) usage;;
esac

File Metadata

Mime Type
text/x-diff
Expires
Thu, Oct 16, 3:04 PM (11 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2536419
Default Alt Text
(27 KB)

Event Timeline