[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/rgmanager/src/resources apache.sh mysq ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	mgrac sourceware org	2006-09-18 13:48:07

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

Log message:
	PID files are stored in common directory. Name of the PID file is generated from the OCF_RESOURCE_INSTANCE. Resource agents for Apache, MySQL and OpenLDAP are updated.

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

--- cluster/rgmanager/src/resources/apache.sh	2006/09/14 13:53:50	1.2
+++ cluster/rgmanager/src/resources/apache.sh	2006/09/18 13:48:07	1.3
@@ -27,23 +27,21 @@
 export LANG=C
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
-declare APACHE_HTTPD=/usr/sbin/httpd
-declare APACHE_genConfig="/tmp/httpd.$OCF_RESKEY_name"
-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_HTTPD=/usr/sbin/httpd
+declare APACHE_genConfig="/tmp/httpd.$OCF_RESKEY_name"
+declare APACHE_serverConfigFile
+declare APACHE_pid_file="`generate_name_for_pid_file`"
+
 declare APACHE_parseConfig=$(dirname $0)/utils/httpd-parse-config.pl
 
 apache_pidFile()
 {
 	declare tmpFile="/tmp/httpd.$OCF_RESKEY_name.$$"
-	declare CFG_pidFile
 	declare CFG_serverRoot
 
 	if [ -f "$APACHE_genConfig" ]; then
@@ -58,25 +56,13 @@
 		generate_configFile "$APACHE_serverConfigFile" "$tmpFile"
 	fi	
 
-	CFG_pidFile=`grep -e '^PidFile' "$tmpFile" | head -n 1 | \
-		sed 's/^PidFile "\(.*\)"/\1/;s/^PidFile \(.*\)/\1/'`
 	CFG_serverRoot=`grep -e '^ServerRoot' "$tmpFile" | head -n 1 | \
 		sed 's/^ServerRoot "\(.*\)"/\1/;s/^ServerRoot \(.*\)/\1/'`
 
-	if [ -z "$CFG_pidFile" ]; then
-		CFG_pidFile="$APACHE_defaultPidFile"
-	fi
-
 	if [ -z "$CFG_serverRoot" ]; then
 		CFG_serverRoot="$OCF_RESKEY_serverRoot"
 	fi
 
-	if [[ "$CFG_pidFile" =~ '^/' ]]; then
-		APACHE_pid_file="$CFG_pidFile"
-	else 
-		APACHE_pid_file="$CFG_serverRoot/$CFG_pidFile"
-	fi
-
 	rm -f "$tmpFile"
 
 	return;
@@ -159,7 +145,6 @@
 	cat >> "$generatedConfigFile" << EOT
 # From a cluster perspective, the key fields are:
 #     Listen - must be set to service floating IP address.
-#     PidFile - path to the file where PID of running application is stored
 #     ServerRoot - path to the ServerRoot (initial value is set in service conf)
 #
 
@@ -177,7 +162,10 @@
 	done;
 	IFS="$IFS_old"
 
-	cat "$originalConfigFile" | sed 's/^Listen/### Listen/;s/^Port/### Port/' | \
+	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"
@@ -191,6 +179,8 @@
 
 	clog_service_start $CLOG_INIT	
 
+	create_pid_directory
+
 	if [ -e "$APACHE_pid_file" ]; then
 		clog_check_pid $CLOG_FAILED "$APACHE_pid_file"
 		clog_service_start $CLOG_FAILED
@@ -237,21 +227,14 @@
 {
 	clog_service_stop $CLOG_INIT
 
-	if [ ! -e "$APACHE_pid_file" ]; then
-		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$APACHE_pid_file"
-		clog_service_stop $CLOG_FAILED
-		return $OCF_ERR_GENERIC
-	fi
-
-	"$APACHE_HTTPD" -k stop
-
+	stop_generic "$APACHE_pid_file"
+	
 	if [ $? -ne 0 ]; then
 		clog_service_stop $CLOG_FAILED
 		return $OCF_ERR_GENERIC
-	else
-		clog_service_stop $CLOG_SUCCEED
 	fi
 	
+	clog_service_stop $CLOG_SUCCEED
 	return 0;
 }
 
@@ -276,7 +259,7 @@
 		
 case $1 in
 	meta-data)
-		cat $(dirname $0)/apache.metadata
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
 		exit 0
 		;;
 	verify-all)
--- cluster/rgmanager/src/resources/mysql.sh	2006/09/14 13:53:50	1.3
+++ cluster/rgmanager/src/resources/mysql.sh	2006/09/18 13:48:07	1.4
@@ -27,16 +27,16 @@
 export LANG=C
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
-declare MYSQL_MYSQLD=/usr/bin/mysqld_safe
-declare MYSQL_ipAddress
-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
 
+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
@@ -73,6 +73,8 @@
 	
 	clog_service_start $CLOG_INIT
 
+	create_pid_directory
+
 	if [ -e "$MYSQL_pid_file" ]; then
 		clog_check_pid $CLOG_FAILED "$MYSQL_pid_file"
 		clog_service_start $CLOG_FAILED
@@ -136,21 +138,14 @@
 {
 	clog_service_stop $CLOG_INIT
 
-	if [ ! -e "$MYSQL_pid_file" ]; then
-		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$MYSQL_pid_file"
-		clog_service_stop $CLOG_FAILED
-		return $OCF_ERR_GENERIC
-	fi
-
-	kill `cat "$MYSQL_pid_file"`
-
+	stop_generic "$MYSQL_pid_file"
+	
 	if [ $? -ne 0 ]; then
 		clog_service_stop $CLOG_FAILED
 		return $OCF_ERR_GENERIC
-	else
-		clog_service_stop $CLOG_SUCCEED
 	fi
 	
+	clog_service_stop $CLOG_SUCCEED
 	return 0;
 }
 
@@ -170,7 +165,7 @@
 
 case $1 in
 	meta-data)
-		cat $(dirname $0)/mysql.metadata
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
 		exit 0
 		;;
 	verify-all)
--- cluster/rgmanager/src/resources/openldap.sh	2006/09/14 13:53:50	1.2
+++ cluster/rgmanager/src/resources/openldap.sh	2006/09/18 13:48:07	1.3
@@ -27,15 +27,16 @@
 export LANG=C
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
-declare LDAP_SLAPD=/usr/sbin/slapd
-declare LDAP_pid_file=/var/run/slapd.pid
-declare LDAP_url_list
-
 . $(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_gen_config_file="/tmp/openldap.$OCF_RESKEY_name"
+declare LDAP_url_list
+
 verify_all()
 {
 	clog_service_verify $CLOG_INIT
@@ -88,6 +89,31 @@
 	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()
 {
@@ -95,6 +121,8 @@
 	
 	clog_service_start $CLOG_INIT
 
+	create_pid_directory
+
 	if [ -e "$LDAP_pid_file" ]; then
 		clog_check_pid $CLOG_FAILED "$LDAP_pid_file"
 		clog_service_start $CLOG_FAILED
@@ -126,7 +154,9 @@
 		return $OCF_ERR_GENERIC
 	fi
 
-	$LDAP_SLAPD -f "$OCF_RESKEY_config_file" -n "$OCF_RESOURCE_INSTANCE" \
+	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
@@ -143,21 +173,14 @@
 {
 	clog_service_stop $CLOG_INIT
 
-	if [ ! -e "$LDAP_pid_file" ]; then
-		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$LDAP_pid_file"
-		clog_service_stop $CLOG_FAILED
-		return $OCF_ERR_GENERIC
-	fi
-
-	kill `cat "$LDAP_pid_file"`
-
+	stop_generic "$LDAP_pid_file"
+	
 	if [ $? -ne 0 ]; then
 		clog_service_stop $CLOG_FAILED
 		return $OCF_ERR_GENERIC
-	else
-		clog_service_stop $CLOG_SUCCEED
 	fi
 	
+	clog_service_stop $CLOG_SUCCEED
 	return 0;
 }
 
--- cluster/rgmanager/src/resources/utils/config-utils.sh	2006/08/31 13:52:21	1.1
+++ cluster/rgmanager/src/resources/utils/config-utils.sh	2006/09/18 13:48:07	1.2
@@ -19,6 +19,8 @@
 #  MA 02139, USA.
 #
 
+declare RA_COMMON_pid_dir=/var/run/cluster
+
 declare -i FAIL=-1
 declare -a ip_keys
 
@@ -214,4 +216,32 @@
         done
 
         echo $ipaddrs
+}
+
+generate_name_for_pid_file()
+{
+	declare filename=$(basename $0)
+	
+	echo "$RA_COMMON_pid_dir/$(basename $0 | sed 's/^\(.*\)\..*/\1/')/$OCF_RESOURCE_INSTANCE.pid"
+	
+	return 0;
+}
+
+create_pid_directory()
+{
+	declare program_name="$(basename $0 | sed 's/^\(.*\)\..*/\1/')"
+	declare dirname="$RA_COMMON_pid_dir/$program_name"
+
+	if [ -d "$dirname" ]; then
+		return 0;
+	fi
+	
+	chmod 711 "$RA_COMMON_pid_dir"
+	mkdir -p "$dirname"
+	
+	if [ "$program_name" = "mysql" ]; then
+		chown mysql.root "$dirname"
+	fi
+
+	return 0;
 }
\ No newline at end of file
--- cluster/rgmanager/src/resources/utils/ra-skelet.sh	2006/09/14 13:53:50	1.1
+++ cluster/rgmanager/src/resources/utils/ra-skelet.sh	2006/09/18 13:48:07	1.2
@@ -24,7 +24,7 @@
 #
 status_check_pid()
 {
-	declare pid_file=$1
+	declare pid_file="$1"
 
 	if [ -z "$pid_file" ]; then
 		clog_check_file_exist $CLOG_FAILED_INVALID "$pid_file"
@@ -42,3 +42,22 @@
 
 	return 0
 }
+
+stop_generic()
+{
+	declare pid_file="$1"
+
+	if [ ! -e "$pid_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$pid_file"
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	kill -TERM `cat "$pid_file"`
+
+	if [ $? -ne 0 ]; then
+		return $OCF_ERR_GENERIC
+	fi
+	
+	return 0;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]