All of lore.kernel.org
 help / color / mirror / Atom feed
From: mgrac@sourceware.org <mgrac@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/rgmanager/src/resources openldap.sh ap ...
Date: 14 Sep 2006 13:53:51 -0000	[thread overview]
Message-ID: <20060914135351.29338.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	mgrac at sourceware.org	2006-09-14 13:53:50

Modified files:
	rgmanager/src/resources: openldap.sh apache.sh mysql.sh 
Added files:
	rgmanager/src/resources/utils: ra-skelet.sh 

Log message:
	Simplifying scripts:
	The basic method of monitoring service is to check for PID file and test if we have such process. This function should be used by every RA for application.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/utils/ra-skelet.sh.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/openldap.sh.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/apache.sh.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/mysql.sh.diff?cvsroot=cluster&r1=1.2&r2=1.3

/cvs/cluster/cluster/rgmanager/src/resources/utils/ra-skelet.sh,v  -->  standard output
revision 1.1
--- cluster/rgmanager/src/resources/utils/ra-skelet.sh
+++ -	2006-09-14 13:53:50.818575000 +0000
@@ -0,0 +1,44 @@
+#!/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)
+#
+status_check_pid()
+{
+	declare pid_file=$1
+
+	if [ -z "$pid_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_INVALID "$pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+	
+	if [ ! -e "$pid_file" ]; then
+		clog_check_file_exist $CLOG_FAILED "$pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	if [ ! -d /proc/`cat "$pid_file"` ]; then
+		return $OCF_ERR_GENERIC
+	fi	
+
+	return 0
+}
--- cluster/rgmanager/src/resources/openldap.sh	2006/09/14 12:22:32	1.1
+++ cluster/rgmanager/src/resources/openldap.sh	2006/09/14 13:53:50	1.2
@@ -34,6 +34,7 @@
 . $(dirname $0)/ocf-shellfuncs
 . $(dirname $0)/utils/config-utils.sh
 . $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
 
 verify_all()
 {
@@ -97,15 +98,15 @@
 	if [ -e "$LDAP_pid_file" ]; then
 		clog_check_pid $CLOG_FAILED "$LDAP_pid_file"
 		clog_service_start $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
-	clog_looking_for $CLOG_INIT "IP Address"
+	clog_looking_for $CLOG_INIT "IP Addresses"
 
         ccs_fd=$(ccs_connect);
         if [ $? -ne 0 ]; then
 		clog_looking_for $CLOG_FAILED_CCS
-                return $OCF_GENERIC_ERROR
+                return $OCF_ERR_GENERIC
         fi
 
         get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
@@ -113,16 +114,16 @@
 
 	if [ -z "$ip_addresses" ]; then
 		clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 	
-	clog_looking_for $CLOG_SUCCEED "IP Address"
+	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_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
 	$LDAP_SLAPD -f "$OCF_RESKEY_config_file" -n "$OCF_RESOURCE_INSTANCE" \
@@ -130,7 +131,7 @@
 
 	if [ $? -ne 0 ]; then
 		clog_service_start $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
 	clog_service_start $CLOG_SUCCEED
@@ -145,14 +146,14 @@
 	if [ ! -e "$LDAP_pid_file" ]; then
 		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$LDAP_pid_file"
 		clog_service_stop $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
 	kill `cat "$LDAP_pid_file"`
 
 	if [ $? -ne 0 ]; then
 		clog_service_stop $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	else
 		clog_service_stop $CLOG_SUCCEED
 	fi
@@ -164,17 +165,12 @@
 {
 	clog_service_status $CLOG_INIT
 
-	if [ ! -e "$LDAP_pid_file" ]; then
-		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$LDAP_pid_file"
-		clog_service_status $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+	status_check_pid "$LDAP_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$LDAP_pid_file"
+		return $OCF_ERR_GENERIC
 	fi
 
-	if [ ! -d /proc/`cat "$LDAP_pid_file"` ]; then
-		clog_service_status $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
-	fi	
-
 	clog_service_status $CLOG_SUCCEED
 	return 0
 }
--- cluster/rgmanager/src/resources/apache.sh	2006/08/31 15:01:10	1.1
+++ cluster/rgmanager/src/resources/apache.sh	2006/09/14 13:53:50	1.2
@@ -29,13 +29,14 @@
 
 declare APACHE_HTTPD=/usr/sbin/httpd
 declare APACHE_genConfig="/tmp/httpd.$OCF_RESKEY_name"
-declare APACHE_pidFile
+declare APACHE_pid_file
 declare APACHE_serverConfigFile
 declare APACHE_defaultPidFile=run/httpd.pid
 
 . $(dirname $0)/ocf-shellfuncs
 . $(dirname $0)/utils/config-utils.sh
 . $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
 
 declare APACHE_parseConfig=$(dirname $0)/utils/httpd-parse-config.pl
 
@@ -71,9 +72,9 @@
 	fi
 
 	if [[ "$CFG_pidFile" =~ '^/' ]]; then
-		APACHE_pidFile="$CFG_pidFile"
+		APACHE_pid_file="$CFG_pidFile"
 	else 
-		APACHE_pidFile="$CFG_serverRoot/$CFG_pidFile"
+		APACHE_pid_file="$CFG_serverRoot/$CFG_pidFile"
 	fi
 
 	rm -f "$tmpFile"
@@ -116,7 +117,7 @@
 		return $OCF_ERR_ARGS
 	fi
 
-	if [ -z "$APACHE_pidFile" ]; then
+	if [ -z "$APACHE_pid_file" ]; then
 		clog_service_verify $CLOG_FAILED "Invalid name of PID file"
 		return $OCF_ERR_ARGS
 	fi
@@ -190,10 +191,10 @@
 
 	clog_service_start $CLOG_INIT	
 
-	if [ -e "$APACHE_pidFile" ]; then
-		clog_check_pid $CLOG_FAILED "$APACHE_pidFile"
+	if [ -e "$APACHE_pid_file" ]; then
+		clog_check_pid $CLOG_FAILED "$APACHE_pid_file"
 		clog_service_start $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
 	clog_looking_for $CLOG_INIT "IP Addresses"
@@ -201,7 +202,7 @@
 	ccs_fd=$(ccs_connect);
 	if [ $? -ne 0 ]; then
 		clog_looking_for $CLOG_FAILED_CCS
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 	
 	get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
@@ -209,7 +210,7 @@
 
 	if [ -z "$ip_addresses" ]; then
 		clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 	
 	clog_looking_for $CLOG_SUCCEED "IP Addresses"
@@ -236,17 +237,17 @@
 {
 	clog_service_stop $CLOG_INIT
 
-	if [ ! -e "$APACHE_pidFile" ]; then
-		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$APACHE_pidFile"
+	if [ ! -e "$APACHE_pid_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$APACHE_pid_file"
 		clog_service_stop $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
 	"$APACHE_HTTPD" -k stop
 
 	if [ $? -ne 0 ]; then
 		clog_service_stop $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	else
 		clog_service_stop $CLOG_SUCCEED
 	fi
@@ -258,17 +259,12 @@
 {
 	clog_service_status $CLOG_INIT
 
-	if [ ! -e "$APACHE_pidFile" ]; then
-		clog_check_file_exist $CLOG_FAILED "$APACHE_pidFile"
-		clog_service_status $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+	status_check_pid "$APACHE_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$APACHE_pid_file"
+		return $OCF_ERR_GENERIC
 	fi
 
-	if [ ! -d /proc/`cat "$APACHE_pidFile"` ]; then
-		clog_service_status $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
-	fi	
-
 	clog_service_status $CLOG_SUCCEED
 	return 0
 }
--- cluster/rgmanager/src/resources/mysql.sh	2006/08/31 15:04:42	1.2
+++ cluster/rgmanager/src/resources/mysql.sh	2006/09/14 13:53:50	1.3
@@ -29,12 +29,13 @@
 
 declare MYSQL_MYSQLD=/usr/bin/mysqld_safe
 declare MYSQL_ipAddress
-declare MYSQL_pidFile="/var/run/mysqld/mysql.$OCF_RESKEY_name.pid"
+declare MYSQL_pid_file="/var/run/mysqld/mysql.$OCF_RESKEY_name.pid"
 declare MYSQL_timeout=30
 
 . $(dirname $0)/ocf-shellfuncs
 . $(dirname $0)/utils/config-utils.sh
 . $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
 
 verify_all()
 {
@@ -57,7 +58,7 @@
 		return $OCF_ERR_ARGS
 	fi
 
-	if [ -z "$MYSQL_pidFile" ]; then
+	if [ -z "$MYSQL_pid_file" ]; then
 		clog_service_verify $CLOG_FAILED "Invalid name of PID file"
 		return $OCF_ERR_ARGS
 	fi
@@ -72,10 +73,10 @@
 	
 	clog_service_start $CLOG_INIT
 
-	if [ -e "$MYSQL_pidFile" ]; then
-		clog_check_pid $CLOG_FAILED "$MYSQL_pidFile"
+	if [ -e "$MYSQL_pid_file" ]; then
+		clog_check_pid $CLOG_FAILED "$MYSQL_pid_file"
 		clog_service_start $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
 	if [ -n "$OCF_RESKEY_ipAddress" ]; then
@@ -86,7 +87,7 @@
 	        ccs_fd=$(ccs_connect);
 	        if [ $? -ne 0 ]; then
 			clog_looking_for $CLOG_FAILED_CCS
-	                return $OCF_GENERIC_ERROR
+	                return $OCF_ERR_GENERIC
 	        fi
 
 	        get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
@@ -105,16 +106,16 @@
 	clog_looking_for $CLOG_SUCCEED "IP Address"
 
 	$MYSQL_MYSQLD --defaults-file="$OCF_RESKEY_configFile" \
-		--pid-file="$MYSQL_pidFile" \
+		--pid-file="$MYSQL_pid_file" \
 		--bind-address="$MYSQL_ipAddress" > /dev/null 2>&1 &
 
 	if [ $? -ne 0 ]; then
 		clog_service_start $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
 	while [ "$MYSQL_timeout" -gt 0 ]; do
-		if [ -f "$MYSQL_pidFile" ]; then
+		if [ -f "$MYSQL_pid_file" ]; then
 			break;			
 		fi
 		sleep 1
@@ -123,7 +124,7 @@
 
         if [ "$MYSQL_timeout" -eq 0 ]; then
 		clog_service_start $CLOG_FAILED_TIMEOUT
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 	
 	clog_service_start $CLOG_SUCCEED
@@ -135,17 +136,17 @@
 {
 	clog_service_stop $CLOG_INIT
 
-	if [ ! -e "$MYSQL_pidFile" ]; then
-		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$MYSQL_pidFile"
+	if [ ! -e "$MYSQL_pid_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$MYSQL_pid_file"
 		clog_service_stop $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	fi
 
-	kill `cat "$MYSQL_pidFile"`
+	kill `cat "$MYSQL_pid_file"`
 
 	if [ $? -ne 0 ]; then
 		clog_service_stop $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+		return $OCF_ERR_GENERIC
 	else
 		clog_service_stop $CLOG_SUCCEED
 	fi
@@ -157,17 +158,12 @@
 {
 	clog_service_status $CLOG_INIT
 
-	if [ ! -e "$MYSQL_pidFile" ]; then
-		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$MYSQL_pidFile"
-		clog_service_status $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
+	status_check_pid "$MYSQL_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$MYSQL_pid_file"
+		return $OCF_ERR_GENERIC
 	fi
 
-	if [ ! -d /proc/`cat "$MYSQL_pidFile"` ]; then
-		clog_service_status $CLOG_FAILED
-		return $OCF_GENERIC_ERROR
-	fi	
-
 	clog_service_status $CLOG_SUCCEED
 	return 0
 }



                 reply	other threads:[~2006-09-14 13:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060914135351.29338.qmail@sourceware.org \
    --to=mgrac@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.