From mboxrd@z Thu Jan 1 00:00:00 1970 From: mgrac@sourceware.org Date: 10 Oct 2006 13:57:54 -0000 Subject: [Cluster-devel] cluster/rgmanager/src/resources apache.metadat ... Message-ID: <20061010135754.3613.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Branch: RHEL4 Changes by: mgrac at sourceware.org 2006-10-10 13:57:52 Added files: rgmanager/src/resources: apache.metadata apache.sh mysql.metadata mysql.sh openldap.metadata openldap.sh postgres-8.metadata postgres-8.sh samba.metadata samba.sh tomcat-5.metadata tomcat-5.sh Log message: Bug #204403. Resource agents for Apache, MySQL, OpenLDAP, Postgres 8, Samba and Tomcat 5. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/apache.metadata.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.3.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/apache.sh.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.9.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/mysql.metadata.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.3.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/mysql.sh.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.8.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/openldap.metadata.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.2.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/openldap.sh.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.7.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/postgres-8.metadata.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.2.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/postgres-8.sh.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.5.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/samba.metadata.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.2.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/samba.sh.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.5.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/tomcat-5.metadata.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/tomcat-5.sh.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.1.2.1 /cvs/cluster/cluster/rgmanager/src/resources/apache.metadata,v --> standard output revision 1.3.2.1 --- cluster/rgmanager/src/resources/apache.metadata +++ - 2006-10-10 13:57:53.100925000 +0000 @@ -0,0 +1,95 @@ + + + 1.0 + + + This defines an instance of Apache web server + + + Defines an Apache web server + + + + + + Define a name for use in <IfDefine name> directive. + + + Name + + + + + + + Define an alternate initial ServerRoot + + + Initial ServerRoot + + + + + + + Define an alternate ServerConfigFile + + + Initial ServerConfigFile + + + + + + + Other command-line options for httpd + + + Other command-line options for httpd + + + + + + + Wait X seconds for correct end of service shutdown + + + Wait X seconds for correct end of service shutdown + + + + + + + Inherit the service name. We need to know + the service name in order to determine file + systems and IPs for this service. + + + Inherit the service name. + + + + + + + + + + + + + + + + + + + + + + + + + /cvs/cluster/cluster/rgmanager/src/resources/apache.sh,v --> standard output revision 1.9.2.1 --- cluster/rgmanager/src/resources/apache.sh +++ - 2006-10-10 13:57:53.180551000 +0000 @@ -0,0 +1,277 @@ +#!/bin/bash + +# +# Copyright Red Hat, Inc. 2006 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. +# +# +# Author(s): +# Marek Grac (mgrac at redhat.com) +# + +export LC_ALL=C +export LANG=C +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +. $(dirname $0)/ocf-shellfuncs +. $(dirname $0)/utils/config-utils.sh +. $(dirname $0)/utils/messages.sh +. $(dirname $0)/utils/ra-skelet.sh + +declare APACHE_HTTPD=/usr/sbin/httpd +declare APACHE_serverConfigFile +declare APACHE_pid_file="`generate_name_for_pid_file`" +declare APACHE_conf_dir="`generate_name_for_conf_dir`" +declare APACHE_genConfig="$APACHE_conf_dir/httpd.conf" + +declare APACHE_parseConfig=$(dirname $0)/utils/httpd-parse-config.pl + +apache_serverConfigFile() +{ + if [[ "$OCF_RESKEY_config_file" =~ '^/' ]]; then + APACHE_serverConfigFile="$OCF_RESKEY_config_file" + else + APACHE_serverConfigFile="$OCF_RESKEY_server_root/$OCF_RESKEY_config_file" + fi + + return; +} + +verify_all() +{ + clog_service_verify $CLOG_INIT + + if [ -z "$OCF_RESKEY_name" ]; then + clog_service_verify $CLOG_FAILED "Invalid Name Of Service" + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_service_name" ]; then + clog_service_verify $CLOG_FAILED_NOT_CHILD + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_server_root" ]; then + clog_service_verify $CLOG_FAILED "Invalid ServerRoot" + return $OCF_ERR_ARGS + fi + + if [ ! -d "$OCF_RESKEY_server_root" ]; then + clog_service_verify $CLOG_FAILED "ServerRoot Directory Is Missing" + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file" + return $OCF_ERR_ARGS + fi + + if [ ! -r "$APACHE_serverConfigFile" ]; then + clog_check_file_exist $CLOG_FAILED_NOT_READABLE "$APACHE_config_file" + return $OCF_ERR_ARGS + fi + + if [ -z "$APACHE_pid_file" ]; then + clog_service_verify $CLOG_FAILED "Invalid name of PID file" + return $OCF_ERR_ARGS + fi + + clog_check_syntax $CLOG_INIT "$APACHE_serverConfigFile" + + "$APACHE_HTTPD" -t \ + -D"$OCF_RESKEY_name" \ + -d "$OCF_RESKEY_server_root" \ + -f "$APACHE_serverConfigFile" \ + $OCF_RESKEY_httpd_options &> /dev/null + + if [ $? -ne 0 ]; then + clog_check_syntax $CLOG_FAILED "$APACHE_config_file" + return $OCF_ERR_GENERIC + fi + + clog_check_syntax $CLOG_SUCCEED "$APACHE_config_file" + + return 0 +} + +generate_configFile() +{ + declare originalConfigFile=$1; + declare generatedConfigFile=$2; + declare ip_addresses=$3; + + if [ -f "$generatedConfigFile" ]; then + sha1_verify "$generatedConfigFile" + if [ $? -ne 0 ]; then + clog_check_sha1 $CLOG_FAILED + return 0 + fi + fi + + clog_generate_config $CLOG_INIT "$originalConfigFile" "$generatedConfigFile" + + generate_configTemplate "$generatedConfigFile" "$1" + cat >> "$generatedConfigFile" << EOT +# From a cluster perspective, the key fields are: +# Listen - must be set to service floating IP address. +# ServerRoot - path to the ServerRoot (initial value is set in service conf) +# + +EOT + + IFS_old="$IFS" + IFS=$'\n' + for i in `"$APACHE_parseConfig" -D"$OCF_RESKEY_name" < "$originalConfigFile" | grep -P '(^Listen)|(^Port)' | grep -v ':'`; do + port=`echo $i | sed 's/^Listen \(.*\)/\1/;s/^Port \(.*\)/\1/'`; + IFS=$' '; + for z in $ip_addresses; do + echo "Listen $z:$port" >> "$generatedConfigFile"; + done + IFS=$'\n'; + done; + IFS="$IFS_old" + + echo "PidFile \"$APACHE_pid_file\"" >> "$generatedConfigFile"; + echo >> "$generatedConfigFile" + + cat "$originalConfigFile" | sed 's/^Listen/### Listen/;s/^Port/### Port/;s/^PidFile/### PidFile/' | \ + "$APACHE_parseConfig" -D"$OCF_RESKEY_name" >> "$generatedConfigFile" + + sha1_addToFile "$generatedConfigFile" + clog_generate_config $CLOG_SUCCEED "$originalConfigFile" "$generatedConfigFile" +} + +start() +{ + declare ccs_fd + declare ip_addresses + + clog_service_start $CLOG_INIT + + create_pid_directory + create_conf_directory "$APACHE_conf_dir" + check_pid_file "$APACHE_pid_file" + + if [ $? -ne 0 ]; then + clog_check_pid $CLOG_FAILED "$APACHE_pid_file" + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_INIT "IP Addresses" + + ccs_fd=$(ccs_connect); + if [ $? -ne 0 ]; then + clog_looking_for $CLOG_FAILED_CCS + return $OCF_ERR_GENERIC + fi + + get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name" + ip_addresses=`build_ip_list "$ccs_fd"` + + if [ -z "$ip_addresses" ]; then + clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses" + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_SUCCEED "IP Addresses" + + generate_configFile "$APACHE_serverConfigFile" "$APACHE_genConfig" "$ip_addresses" + + "$APACHE_HTTPD" \ + "-D$OCF_RESKEY_name" \ + -d "$OCF_RESKEY_server_root" \ + -f "$APACHE_genConfig" \ + $OCF_RESKEY_httpd_options \ + -k start + + if [ $? -ne 0 ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + else + clog_service_start $CLOG_SUCCEED + fi + + return 0; +} + +stop() +{ + clog_service_stop $CLOG_INIT + + stop_generic "$APACHE_pid_file" "$OCF_RESKEY_shutdown_wait" + + if [ $? -ne 0 ]; then + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_service_stop $CLOG_SUCCEED + return 0; +} + +status() +{ + clog_service_status $CLOG_INIT + + status_check_pid "$APACHE_pid_file" + if [ $? -ne 0 ]; then + clog_service_status $CLOG_FAILED "$APACHE_pid_file" + return $OCF_ERR_GENERIC + fi + + clog_service_status $CLOG_SUCCEED + return 0 +} + +if [ "$1" != "meta-data" ]; then + apache_serverConfigFile +fi; + +case $1 in + meta-data) + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` + exit 0 + ;; + verify-all) + verify_all + exit $? + ;; + start) + verify_all && start + exit $? + ;; + stop) + verify_all && stop + exit $? + ;; + status|monitor) + verify_all + status + exit $? + ;; + restart) + verify_all + stop + start + exit $? + ;; + *) + echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}" + exit $OCF_ERR_GENERIC + ;; +esac /cvs/cluster/cluster/rgmanager/src/resources/mysql.metadata,v --> standard output revision 1.3.2.1 --- cluster/rgmanager/src/resources/mysql.metadata +++ - 2006-10-10 13:57:53.265749000 +0000 @@ -0,0 +1,96 @@ + + + 1.0 + + + This defines an instance of MySQL database server + + + Defines a MySQL database server + + + + + + Define a name + + + Name + + + + + + + Define configuration file + + + Define configuration file + + + + + + + Define an IP address for MySQL + + + Define an IP address for MySQL server. If the address + is not given then first IP address from the service is taken. + + + + + + + Other command-line options for httpd + + + Other command-line options for httpd + + + + + + + Wait X seconds for correct end of service shutdown + + + Wait X seconds for correct end of service shutdown + + + + + + + Inherit the service name. We need to know + the service name in order to determine file + systems and IPs for this service. + + + Inherit the service name. + + + + + + + + + + + + + + + + + + + + + + + + + /cvs/cluster/cluster/rgmanager/src/resources/mysql.sh,v --> standard output revision 1.8.2.1 --- cluster/rgmanager/src/resources/mysql.sh +++ - 2006-10-10 13:57:53.345173000 +0000 @@ -0,0 +1,205 @@ +#!/bin/bash + +# +# Copyright Red Hat, Inc. 2006 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. +# +# +# Author(s): +# Marek Grac (mgrac at redhat.com) +# + +export LC_ALL=C +export LANG=C +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +. $(dirname $0)/ocf-shellfuncs +. $(dirname $0)/utils/config-utils.sh +. $(dirname $0)/utils/messages.sh +. $(dirname $0)/utils/ra-skelet.sh + +declare MYSQL_MYSQLD=/usr/bin/mysqld_safe +declare MYSQL_ipAddress +declare MYSQL_pid_file="`generate_name_for_pid_file`" +declare MYSQL_timeout=30 + +verify_all() +{ + clog_service_verify $CLOG_INIT + + if [ -z "$OCF_RESKEY_name" ]; then + clog_service_verify $CLOG_FAILED "Invalid Name Of Service" + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_service_name" ]; then + clog_service_verify $CLOG_FAILED_NOT_CHILD + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file" + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + if [ ! -r "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + if [ -z "$MYSQL_pid_file" ]; then + clog_service_verify $CLOG_FAILED "Invalid name of PID file" + return $OCF_ERR_ARGS + fi + + clog_service_verify $CLOG_SUCCEED + return 0 +} + +start() +{ + declare ccs_fd; + + clog_service_start $CLOG_INIT + + create_pid_directory + check_pid_file "$MYSQL_pid_file" + + if [ $? -ne 0 ]; then + clog_check_pid $CLOG_FAILED "$MYSQL_pid_file" + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + if [ -n "$OCF_RESKEY_listen_address" ]; then + MYSQL_ipAddress="$OCF_RESKEY_listen_address" + else + clog_looking_for $CLOG_INIT "IP Address" + + ccs_fd=$(ccs_connect); + if [ $? -ne 0 ]; then + clog_looking_for $CLOG_FAILED_CCS + return $OCF_ERR_GENERIC + fi + + get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name" + ip_addresses=`build_ip_list "$ccs_fd"` + + if [ -n "$ip_addresses" ]; then + for i in $ip_addresses; do + MYSQL_ipAddress="$i" + break; + done + else + clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Address" + fi + fi + + clog_looking_for $CLOG_SUCCEED "IP Address" + + $MYSQL_MYSQLD --defaults-file="$OCF_RESKEY_config_file" \ + --pid-file="$MYSQL_pid_file" \ + --bind-address="$MYSQL_ipAddress" \ + $OCF_RESKEY_mysqld_options > /dev/null 2>&1 & + + if [ $? -ne 0 ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + while [ "$MYSQL_timeout" -gt 0 ]; do + if [ -f "$MYSQL_pid_file" ]; then + break; + fi + sleep 1 + let MYSQL_timeout=${MYSQL_timeout}-1 + done + + if [ "$MYSQL_timeout" -eq 0 ]; then + clog_service_start $CLOG_FAILED_TIMEOUT + return $OCF_ERR_GENERIC + fi + + clog_service_start $CLOG_SUCCEED + + return 0; +} + +stop() +{ + clog_service_stop $CLOG_INIT + + stop_generic "$MYSQL_pid_file" "$OCF_RESKEY_shutdown_wait" + + if [ $? -ne 0 ]; then + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_service_stop $CLOG_SUCCEED + return 0; +} + +status() +{ + clog_service_status $CLOG_INIT + + status_check_pid "$MYSQL_pid_file" + if [ $? -ne 0 ]; then + clog_service_status $CLOG_FAILED "$MYSQL_pid_file" + return $OCF_ERR_GENERIC + fi + + clog_service_status $CLOG_SUCCEED + return 0 +} + +case $1 in + meta-data) + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` + exit 0 + ;; + verify-all) + verify_all + exit $? + ;; + start) + verify_all && start + exit $? + ;; + stop) + verify_all && stop + exit $? + ;; + status|monitor) + verify_all + status + exit $? + ;; + restart) + verify_all + stop + start + exit $? + ;; + *) + echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}" + exit $OCF_ERR_GENERIC + ;; +esac /cvs/cluster/cluster/rgmanager/src/resources/openldap.metadata,v --> standard output revision 1.2.2.1 --- cluster/rgmanager/src/resources/openldap.metadata +++ - 2006-10-10 13:57:53.424523000 +0000 @@ -0,0 +1,98 @@ + + + 1.0 + + + This defines an instance of Open LDAP + + + Defines an Open LDAP server + + + + + + Specifies a service name for logging and other purposes + + + Name + + + + + + + Define absolute path to configuration file + + + Config File + + + + + + + Serve URL list. Default behaviour of URL list is changed and + enhanced. eg. ldap:/// won't bind all IP address on the + computer but to all IP addresses in service. Using + ldap://0:port/ will bind to all IP addresses for service on + given port. + + + URL list + + + + + + + Other command-line options for slapd + + + Other command-line options for slapd + + + + + + + Wait X seconds for correct end of service shutdown + + + Wait X seconds for correct end of service shutdown + + + + + + + Inherit the service name. We need to know + the service name in order to determine file + systems and IPs for this service. + + + Inherit the service name. + + + + + + + + + + + + + + + + + + + + + + + + /cvs/cluster/cluster/rgmanager/src/resources/openldap.sh,v --> standard output revision 1.7.2.1 --- cluster/rgmanager/src/resources/openldap.sh +++ - 2006-10-10 13:57:53.529402000 +0000 @@ -0,0 +1,240 @@ +#!/bin/bash + +# +# Copyright Red Hat, Inc. 2006 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. +# +# +# Author(s): +# Marek Grac (mgrac at redhat.com) +# + +export LC_ALL=C +export LANG=C +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +. $(dirname $0)/ocf-shellfuncs +. $(dirname $0)/utils/config-utils.sh +. $(dirname $0)/utils/messages.sh +. $(dirname $0)/utils/ra-skelet.sh + +declare LDAP_SLAPD=/usr/sbin/slapd +declare LDAP_pid_file="`generate_name_for_pid_file`" +declare LDAP_conf_dir="`generate_name_for_conf_dir`" +declare LDAP_gen_config_file="$LDAP_conf_dir/slapd.conf" +declare LDAP_url_list + +verify_all() +{ + clog_service_verify $CLOG_INIT + + if [ -z "$OCF_RESKEY_name" ]; then + clog_service_verify $CLOG_FAILED "Invalid Name Of Service" + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_service_name" ]; then + clog_service_verify $CLOG_FAILED_NOT_CHILD + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file" + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + if [ ! -r "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + clog_service_verify $CLOG_SUCCEED + + return 0 +} + +generate_url_list() +{ + declare ldap_url_source=$1 + declare ip_addresses=$2 + declare url_list + declare tmp; + + for u in $ldap_url_source; do + if [[ "$u" =~ ':///' ]]; then + for z in $ip_addresses; do + tmp=`echo $u | sed "s,://,://$z,"` + url_list="$url_list $tmp" + done + elif [[ "$u" =~ '://0:' ]]; then + for z in $ip_addresses; do + tmp=`echo $u | sed "s,://0:,://$z:,"` + url_list="$url_list $tmp" + done + else + url_list="$url_list $u" + fi + done + + echo $url_list +} + +generate_config_file() +{ + declare original_file="$1" + declare generated_file="$2" + + if [ -f "$generated_file" ]; then + sha1_verify "$generated_file" + if [ $? -ne 0 ]; then + clog_check_sha1 $CLOG_FAILED + return 0 + fi + fi + + clog_generate_config $CLOG_INIT "$original_file" "$generated_file" + + generate_configTemplate "$generated_file" "$1" + echo "pidfile \"$LDAP_pid_file\"" >> $generated_file + echo >> $generated_file + sed 's/^[[:space:]]*pidfile/### pidfile/i' < "$original_file" >> "$generated_file" + + sha1_addToFile "$generated_file" + clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file" + + return 0; +} + +start() +{ + declare ccs_fd; + + clog_service_start $CLOG_INIT + + create_pid_directory + create_conf_directory "$LDAP_conf_dir" + check_pid_file "$LDAP_pid_file" + + if [ $? -ne 0 ]; then + clog_check_pid $CLOG_FAILED "$LDAP_pid_file" + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + clog_looking_for $CLOG_INIT "IP Addresses" + + ccs_fd=$(ccs_connect); + if [ $? -ne 0 ]; then + clog_looking_for $CLOG_FAILED_CCS + return $OCF_ERR_GENERIC + fi + + get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name" + ip_addresses=`build_ip_list "$ccs_fd"` + + if [ -z "$ip_addresses" ]; then + clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses" + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_SUCCEED "IP Addresses" + + LDAP_url_list=`generate_url_list "$OCF_RESKEY_url_list" "$ip_addresses"` + + if [ -z "$LDAP_url_list" ]; then + ocf_log error "Generating URL List for $OCF_RESOURCE_INSTANCE > Failed" + return $OCF_ERR_GENERIC + fi + + generate_config_file "$OCF_RESKEY_config_file" "$LDAP_gen_config_file" + + $LDAP_SLAPD -f "$LDAP_gen_config_file" -n "$OCF_RESOURCE_INSTANCE" \ + -h "$LDAP_url_list" $OCF_RESKEY_slapd_options + + if [ $? -ne 0 ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_service_start $CLOG_SUCCEED + + return 0; +} + +stop() +{ + clog_service_stop $CLOG_INIT + + stop_generic "$LDAP_pid_file" "$OCF_RESKEY_shutdown_wait" + + if [ $? -ne 0 ]; then + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_service_stop $CLOG_SUCCEED + return 0; +} + +status() +{ + clog_service_status $CLOG_INIT + + status_check_pid "$LDAP_pid_file" + if [ $? -ne 0 ]; then + clog_service_status $CLOG_FAILED "$LDAP_pid_file" + return $OCF_ERR_GENERIC + fi + + clog_service_status $CLOG_SUCCEED + return 0 +} + +case $1 in + meta-data) + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` + exit 0 + ;; + verify-all) + verify_all + exit $? + ;; + start) + verify_all && start + exit $? + ;; + stop) + verify_all && stop + exit $? + ;; + status|monitor) + verify_all + status + exit $? + ;; + restart) + verify_all + stop + start + exit $? + ;; + *) + echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}" + exit $OCF_ERR_GENERIC + ;; +esac /cvs/cluster/cluster/rgmanager/src/resources/postgres-8.metadata,v --> standard output revision 1.2.2.1 --- cluster/rgmanager/src/resources/postgres-8.metadata +++ - 2006-10-10 13:57:53.610835000 +0000 @@ -0,0 +1,95 @@ + + + 1.0 + + + This defines an instance of PostgreSQL server + + + Defines a PostgreSQL server + + + + + + Specifies a service name for logging and other purposes + + + Name + + + + + + + Define absolute path to configuration file + + + Config File + + + + + + + User who runs the database server because it can't be + run by root. + + + User who runs the database server + + + + + + + Other command-line options for postmaster + + + Other command-line options for postmaster + + + + + + + Wait X seconds for correct end of service shutdown + + + Wait X seconds for correct end of service shutdown + + + + + + + Inherit the service name. We need to know + the service name in order to determine file + systems and IPs for this service. + + + Inherit the service name. + + + + + + + + + + + + + + + + + + + + + + + + /cvs/cluster/cluster/rgmanager/src/resources/postgres-8.sh,v --> standard output revision 1.5.2.1 --- cluster/rgmanager/src/resources/postgres-8.sh +++ - 2006-10-10 13:57:53.710367000 +0000 @@ -0,0 +1,225 @@ +#!/bin/bash + +# +# Copyright Red Hat, Inc. 2006 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. +# +# +# Author(s): +# Marek Grac (mgrac at redhat.com) +# + +export LC_ALL=C +export LANG=C +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +. $(dirname $0)/ocf-shellfuncs +. $(dirname $0)/utils/config-utils.sh +. $(dirname $0)/utils/messages.sh +. $(dirname $0)/utils/ra-skelet.sh + +declare PSQL_POSTMASTER="/usr/bin/postmaster" +declare PSQL_pid_file="`generate_name_for_pid_file`" +declare PSQL_conf_dir="`generate_name_for_conf_dir`" +declare PSQL_gen_config_file="$PSQL_conf_dir/postgresql.conf" + +verify_all() +{ + clog_service_verify $CLOG_INIT + + if [ -z "$OCF_RESKEY_name" ]; then + clog_service_verify $CLOG_FAILED "Invalid Name Of Service" + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_service_name" ]; then + clog_service_verify $CLOG_FAILED_NOT_CHILD + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file" + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + if [ ! -r "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_postmaster_user" ]; then + clog_servicer_verify $CLOG_FAILED "Invalid User" + return $OCF_ERR_ARGS + fi + + clog_service_verify $CLOG_SUCCEED + + return 0 +} + +generate_config_file() +{ + declare original_file="$1" + declare generated_file="$2" + declare ip_addressess="$3" + + declare ip_comma=""; + + if [ -f "$generated_file" ]; then + sha1_verify "$generated_file" + if [ $? -ne 0 ]; then + clog_check_sha1 $CLOG_FAILED + return 0 + fi + fi + + clog_generate_config $CLOG_INIT "$original_file" "$generated_file" + + declare x=1 + for i in $ip_addressess; do + if [ $x -eq 1 ]; then + x=0 + ip_comma=$i + else + ip_comma=$ip_comma,$i + fi + done + + generate_configTemplate "$generated_file" "$1" + echo "external_pid_file = '$PSQL_pid_file'" >> $generated_file + echo "listen_address = '$ip_comma'" >> $generated_file + + echo >> $generated_file + sed 's/^[[:space:]]*external_pid_file/### external_pid_file/i;s/^[[:space:]]*listen_address/### listen_address/i' < "$original_file" >> "$generated_file" + + sha1_addToFile "$generated_file" + clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file" + + return 0; +} + +start() +{ + declare ccs_fd; + + clog_service_start $CLOG_INIT + + create_pid_directory + create_conf_directory "$PSQL_conf_dir" + check_pid_file "$PSQL_pid_file" + + if [ $? -ne 0 ]; then + clog_check_pid $CLOG_FAILED "$PSQL_pid_file" + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_INIT "IP Addresses" + + ccs_fd=$(ccs_connect); + if [ $? -ne 0 ]; then + clog_looking_for $CLOG_FAILED_CCS + return $OCF_ERR_GENERIC + fi + + get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name" + ip_addresses=`build_ip_list "$ccs_fd"` + + if [ -z "$ip_addresses" ]; then + clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses" + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_SUCCEED "IP Addresses" + + generate_config_file "$OCF_RESKEY_config_file" "$PSQL_gen_config_file" "$ip_addresses" + + sudo -u "$OCF_RESKEY_postmaster_user" $PSQL_POSTMASTER -c config_file="$PSQL_gen_config_file" \ + $OCF_RESKEY_postmaster_options + + if [ $? -ne 0 ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_service_start $CLOG_SUCCEED + return 0; +} + +stop() +{ + clog_service_stop $CLOG_INIT + + stop_generic "$PSQL_pid_file" "$OCF_RESKEY_shutdown_wait" + if [ $? -ne 0 ]; then + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_service_stop $CLOG_SUCCEED + return 0; +} + +status() +{ + clog_service_status $CLOG_INIT + + status_check_pid "$PSQL_pid_file" + if [ $? -ne 0 ]; then + clog_service_status $CLOG_FAILED "$PSQL_pid_file" + return $OCF_ERR_GENERIC + fi + + clog_service_status $CLOG_SUCCEED + return 0 +} + +case $1 in + meta-data) + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` + exit 0 + ;; + verify-all) + verify_all + exit $? + ;; + start) + verify_all && start + exit $? + ;; + stop) + verify_all && stop + exit $? + ;; + status|monitor) + verify_all + status + exit $? + ;; + restart) + verify_all + stop + start + exit $? + ;; + *) + echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}" + exit $OCF_ERR_GENERIC + ;; +esac /cvs/cluster/cluster/rgmanager/src/resources/samba.metadata,v --> standard output revision 1.2.2.1 --- cluster/rgmanager/src/resources/samba.metadata +++ - 2006-10-10 13:57:53.812886000 +0000 @@ -0,0 +1,89 @@ + + + 1.0 + + + Dynamic smbd/nmbd resource agent + + + Dynamic smbd/nmbd resource agent + + + + + + Samba Symbolic Name. + + + Samba Name + + + + + + + Define absolute path to configuration file + + + Config File + + + + + + + Other command-line options for smbd + + + Other command-line options for smbd + + + + + + + Other command-line options for nmbd + + + Other command-line options for nmbd + + + + + + + Wait X seconds for correct end of service shutdown + + + Wait X seconds for correct end of service shutdown + + + + + + + Inherit the service name. We need to know + the service name in order to determine file + systems and IPs for this smb service. + + + Inherit the service name. + + + + + + + + + + + + + + + + + /cvs/cluster/cluster/rgmanager/src/resources/samba.sh,v --> standard output revision 1.5.2.1 --- cluster/rgmanager/src/resources/samba.sh +++ - 2006-10-10 13:57:53.892557000 +0000 @@ -0,0 +1,254 @@ +#!/bin/bash + +# +# Copyright Red Hat, Inc. 2006 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. +# +# +# Author(s): +# Marek Grac (mgrac at redhat.com) +# + +export LC_ALL=C +export LANG=C +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +. $(dirname $0)/ocf-shellfuncs +. $(dirname $0)/utils/config-utils.sh +. $(dirname $0)/utils/messages.sh +. $(dirname $0)/utils/ra-skelet.sh + +declare SAMBA_SMBD=/usr/sbin/smbd +declare SAMBA_NMBD=/usr/sbin/nmbd +declare SAMBA_pid_dir="`generate_name_for_pid_dir`" +declare SAMBA_conf_dir="`generate_name_for_conf_dir`" +declare SAMBA_smbd_pid_file="$SAMBA_pid_dir/smbd.pid" +declare SAMBA_nmbd_pid_file="$SAMBA_pid_dir/nmbd.pid" +declare SAMBA_gen_config_file="$SAMBA_conf_dir/smb.conf" + +verify_all() +{ + clog_service_verify $CLOG_INIT + + if [ -z "$OCF_RESKEY_name" ]; then + clog_service_verify $CLOG_FAILED "Invalid Name Of Service" + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_service_name" ]; then + clog_service_verify $CLOG_FAILED_NOT_CHILD + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file" + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + if [ ! -r "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + clog_service_verify $CLOG_SUCCEED + + return 0 +} + +generate_config_file() +{ + declare original_file="$1" + declare generated_file="$2" + declare ip_addresses="$3" + + if [ -f "$generated_file" ]; then + sha1_verify "$generated_file" + if [ $? -ne 0 ]; then + clog_check_sha1 $CLOG_FAILED + return 0 + fi + fi + + clog_generate_config $CLOG_INIT "$original_file" "$generated_file" + + generate_configTemplate "$generated_file" "$1" + + echo "pid directory = \"$SAMBA_pid_dir\"" >> $generated_file + echo "interfaces = $ip_addresses" >> $generated_file + echo "bind interfaces only = Yes" >> $generated_file + echo "netbios name = \"$OCF_RESKEY_name\"" >> $generated_file + echo >> $generated_file + sed 's/^[[:space:]]*pid directory/### pid directory/i;s/^[[:space:]]*interfaces/### interfaces/i;s/^[[:space:]]*bind interfaces only/### bind interfaces only/i;s/^[[:space:]]*netbios name/### netbios name/i' \ + < "$original_file" >> "$generated_file" + + sha1_addToFile "$generated_file" + clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file" + + return 0; +} + +start() +{ + declare ccs_fd; + + clog_service_start $CLOG_INIT + + create_pid_directory + mkdir -p "$SAMBA_pid_dir" + create_conf_directory "$SAMBA_conf_dir" + check_pid_file "$SAMBA_smbd_pid_file" + + if [ $? -ne 0 ]; then + clog_check_pid $CLOG_FAILED "$SAMBA_smbd_pid_file" + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + check_pid_file "$SAMBA_nmbd_pid_file" + + if [ $? -ne 0 ]; then + clog_check_pid $CLOG_FAILED "$SAMBA_nmbd_pid_file" + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_INIT "IP Addresses" + + ccs_fd=$(ccs_connect); + if [ $? -ne 0 ]; then + clog_looking_for $CLOG_FAILED_CCS + return $OCF_ERR_GENERIC + fi + + get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name" + ip_addresses=`build_ip_list "$ccs_fd"` + + if [ -z "$ip_addresses" ]; then + clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses" + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_SUCCEED "IP Addresses" + + generate_config_file "$OCF_RESKEY_config_file" "$SAMBA_gen_config_file" "$ip_addresses" + + $SAMBA_SMBD -D -s "$SAMBA_gen_config_file" $OCF_RESKEY_smbd_options + + if [ $? -ne 0 ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + $SAMBA_NMBD -D -s "$SAMBA_gen_config_file" $OCF_RESKEY_nmbd_options + + if [ $? -ne 0 ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + clog_service_start $CLOG_SUCCEED + + return 0; +} + +stop() +{ + clog_service_stop $CLOG_INIT + + stop_generic "$SAMBA_smbd_pid_file" "$OCF_RESKEY_shutdown_wait" + + if [ $? -ne 0 ]; then + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + stop_generic "$SAMBA_nmbd_pid_file" + + if [ $? -ne 0 ]; then + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + if [ -e "$SAMBA_smbd_pid_file" ]; then + rm -f "$SAMBA_smbd_pid_file" + fi + + if [ -e "$SAMBA_nmbd_pid_file" ]; then + rm -f "$SAMBA_nmbd_pid_file" + fi + + clog_service_stop $CLOG_SUCCEED + return 0; +} + +status() +{ + clog_service_status $CLOG_INIT + + status_check_pid "$SAMBA_smbd_pid_file" + + if [ $? -ne 0 ]; then + clog_service_status $CLOG_FAILED "$SAMBA_smbd_pid_file" + return $OCF_ERR_GENERIC + fi + + status_check_pid "$SAMBA_nmbd_pid_file" + + if [ $? -ne 0 ]; then + clog_service_status $CLOG_FAILED "$SAMBA_nmbd_pid_file" + return $OCF_ERR_GENERIC + fi + + clog_service_status $CLOG_SUCCEED + return 0 +} + +case $1 in + meta-data) + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` + exit 0 + ;; + verify-all) + verify_all + exit $? + ;; + start) + verify_all && start + exit $? + ;; + stop) + verify_all && stop + exit $? + ;; + status|monitor) + verify_all + status + exit $? + ;; + restart) + verify_all + stop + start + exit $? + ;; + *) + echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}" + exit $OCF_ERR_GENERIC + ;; +esac /cvs/cluster/cluster/rgmanager/src/resources/tomcat-5.metadata,v --> standard output revision 1.1.2.1 --- cluster/rgmanager/src/resources/tomcat-5.metadata +++ - 2006-10-10 13:57:53.983759000 +0000 @@ -0,0 +1,104 @@ + + + 1.0 + + + This defines an instance of Tomcat server + + + Defines a Tomcat server + + + + + + Specifies a service name for logging and other purposes + + + Name + + + + + + + Define absolute path to configuration file + + + Config File + + + + + + + User who runs the Tomcat server + + + User who runs the Tomcat server + + + + + + + Other command-line options for Catalina + + + Other command-line options for Catalina + + + + + + + Cataliny base directory + + + Catalina base directory (differs for each service) + + + + + + + Wait X seconds for correct end of service shutdown + + + Wait X seconds for correct end of service shutdown + + + + + + + Inherit the service name. We need to know + the service name in order to determine file + systems and IPs for this service. + + + Inherit the service name. + + + + + + + + + + + + + + + + + + + + + + + + /cvs/cluster/cluster/rgmanager/src/resources/tomcat-5.sh,v --> standard output revision 1.1.2.1 --- cluster/rgmanager/src/resources/tomcat-5.sh +++ - 2006-10-10 13:57:54.079389000 +0000 @@ -0,0 +1,287 @@ +#!/bin/bash + +# +# Copyright Red Hat, Inc. 2006 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU Gener5~al Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, +# MA 02139, USA. +# +# +# Author(s): +# Marek Grac (mgrac at redhat.com) +# + +export LC_ALL=C +export LANG=C +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +. $(dirname $0)/ocf-shellfuncs +. $(dirname $0)/utils/config-utils.sh +. $(dirname $0)/utils/messages.sh +. $(dirname $0)/utils/ra-skelet.sh + +declare TOMCAT_TOMCAT=/usr/bin/dtomcat5 +declare TOMCAT_RELINK=/usr/share/tomcat5/bin/relink +declare TOMCAT_pid_file="`generate_name_for_pid_file`" +declare TOMCAT_conf_dir="`generate_name_for_conf_dir`/conf" +declare TOMCAT_gen_config_file="$TOMCAT_conf_dir/server.xml" +declare TOMCAT_gen_catalina_base="`generate_name_for_conf_dir`" + +declare JAVA_HOME +declare CATALINA_HOME +declare CATALINA_BASE +declare CATALINA_TMPDIR +declare CLASSPATH +declare TOMCAT_USER +## + +verify_all() +{ + clog_service_verify $CLOG_INIT + + if [ -z "$OCF_RESKEY_name" ]; then + clog_service_verify $CLOG_FAILED "Invalid Name Of Service" + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_service_name" ]; then + clog_service_verify $CLOG_FAILED_NOT_CHILD + return $OCF_ERR_ARGS + fi + + if [ -z "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file" + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + if [ ! -r "$OCF_RESKEY_config_file" ]; then + clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file + clog_service_verify $CLOG_FAILED + return $OCF_ERR_ARGS + fi + + . "$OCF_RESKEY_config_file" + + if [ $? -ne 0 ]; then + clog_service_verify $CLOG_FAILED "Error In The File \"$OCF_RESKEY_config_file\"" + return $OCF_ERR_ARGS + fi + + if [ -z "$JAVA_HOME" ]; then + clog_service_verify $CLOG_FAILED "JAVA_HOME Not Specified In ${OCF_RESKEY_config_file}" + return $OCF_ERR_ARGS; + fi + + if [ ! -d "$JAVA_HOME" ]; then + clog_service_verify $CLOG_FAILED "JAVA_HOME Does Not Exist" + return $OCF_ERR_ARGS; + fi + + if [ -z "$JAVA_ENDORSED_DIRS" ]; then + clog_service_verify $CLOG_FAILED "JAVA_ENDORSED_DIRS Not Specified In ${OCF_RESKEY_config_file}" + return $OCF_ERR_ARGS; + fi + + if [ ! -d "$JAVA_ENDORSED_DIRS" ]; then + clog_service_verify $CLOG_FAILED "JAVA_ENDORSED_DIRS Does Not Exist" + return $OCF_ERR_ARGS; + fi + + if [ -z "$CATALINA_HOME" ]; then + clog_service_verify $CLOG_FAILED "CATALINA_HOME Not Specified In ${OCF_RESKEY_config_file}" + return $OCF_ERR_ARGS; + fi + + if [ ! -d "$CATALINA_HOME" ]; then + clog_service_verify $CLOG_FAILED "CATALINA_HOME Does Not Exist" + return $OCF_ERR_ARGS; + fi + + if [ -z "$CATALINA_TMPDIR" ]; then + clog_service_verify $CLOG_FAILED "CATALINA_TMPDIR Not Specified In ${OCF_RESKEY_config_file}" + return $OCF_ERR_ARGS; + fi + + if [ ! -d "$CATALINA_TMPDIR" ]; then + clog_service_verify $CLOG_FAILED "CATALINA_TMPDIR Does Not Exist" + return $OCF_ERR_ARGS; + fi + + if [ -z "$TOMCAT_USER" ]; then + clog_service_verify $CLOG_FAILED "TOMCAT_USER Does Not Exist" + return $OCF_ERR_ARGS; + fi + + clog_service_verify $CLOG_SUCCEED + + return 0 +} + +generate_config_file() +{ + declare original_file="$1" + declare generated_file="$2" + declare ip_addresses="$3" + + if [ -f "$generated_file" ]; then + sha1_verify "$generated_file" + if [ $? -ne 0 ]; then + clog_check_sha1 $CLOG_FAILED + return 0 + fi + fi + + clog_generate_config $CLOG_INIT "$original_file" "$generated_file" + +# generate_configTemplate "$generated_file" "$original_file" + $(dirname $0)/utils/tomcat-parse-config.pl $ip_addresses < "$original_file" >> "$generated_file" + + sha1_addToFile "$generated_file" + clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file" + + return 0; +} + +start() +{ + declare ccs_fd; + + clog_service_start $CLOG_INIT + + create_pid_directory + create_conf_directory "$TOMCAT_conf_dir" + check_pid_file "$TOMCAT_pid_file" + + if [ $? -ne 0 ]; then + clog_check_pid $CLOG_FAILED "$TOMCAT_pid_file" + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + clog_looking_for $CLOG_INIT "IP Addresses" + + ccs_fd=$(ccs_connect); + if [ $? -ne 0 ]; then + clog_looking_for $CLOG_FAILED_CCS + return $OCF_ERR_GENERIC + fi + + get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name" + ip_addresses=`build_ip_list "$ccs_fd"` + + if [ -z "$ip_addresses" ]; then + clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses" + return $OCF_ERR_GENERIC + fi + + clog_looking_for $CLOG_SUCCEED "IP Addresses" + generate_config_file "$OCF_RESKEY_catalina_base/conf/server.xml" "$TOMCAT_gen_config_file" "$ip_addresses" + ln -s "$OCF_RESKEY_catalina_base"/* "$TOMCAT_gen_catalina_base" &> /dev/null + ln -s "$OCF_RESKEY_catalina_base"/conf/* "$TOMCAT_gen_catalina_base"/conf &> /dev/null + + CLASSPATH="$JAVA_HOME"/lib/tools.jar:"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar:`/usr/bin/build-classpath mx4j/mx4j-impl`:`/usr/bin/build-classpath mx4j/mx4j-jmx` + + sudo -u "$TOMCAT_USER" "$JAVA_HOME/bin/java" $JAVA_OPTS $OCF_RESKEY_catalina_options \ + -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ + -Dcatalina.base="$TOMCAT_gen_catalina_base" \ + -Dcatalina.home="$CATALINA_HOME" \ + -Djava.io.tmpdir="$CATALINA_TMPDIR" \ + org.apache.catalina.startup.Bootstrap "$@" start \ + >> "$TOMCAT_gen_catalina_base"/logs/catalina.out 2>&1 & + + + if [ $? -ne 0 ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + if [ -z "$!" ]; then + clog_service_start $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + echo $! > $TOMCAT_pid_file + + clog_service_start $CLOG_SUCCEED + + return 0; +} + +stop() +{ + clog_service_stop $CLOG_INIT + + stop_generic "$TOMCAT_pid_file" "$OCF_RESKEY_shutdown_wait" + + if [ $? -ne 0 ]; then + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + if [ -e "$TOMCAT_pid_file" ]; then + rm -f "$TOMCAT_pid_file" + fi + + clog_service_stop $CLOG_SUCCEED + return 0; +} + +status() +{ + clog_service_status $CLOG_INIT + + status_check_pid "$TOMCAT_pid_file" + if [ $? -ne 0 ]; then + clog_service_status $CLOG_FAILED "$TOMCAT_pid_file" + return $OCF_ERR_GENERIC + fi + + clog_service_status $CLOG_SUCCEED + return 0 +} + +case $1 in + meta-data) + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` + exit 0 + ;; + verify-all) + verify_all + exit $? + ;; + start) + verify_all && start + exit $? + ;; + stop) + verify_all && stop + exit $? + ;; + status|monitor) + verify_all + status + exit $? + ;; + restart) + verify_all + stop + start + exit $? + ;; + *) + echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}" + exit $OCF_ERR_GENERIC + ;; +esac