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 utils/ra-skele ...
Date: 20 Sep 2006 07:14:55 -0000	[thread overview]
Message-ID: <20060920071455.12404.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	mgrac at sourceware.org	2006-09-20 07:14:55

Modified files:
	rgmanager/src/resources/utils: ra-skelet.sh 
Added files:
	rgmanager/src/resources: postgres-8.metadata postgres-8.sh 

Log message:
	Bug #204058. Adding resource agent for PostgreSQL 8

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

/cvs/cluster/cluster/rgmanager/src/resources/postgres-8.metadata,v  -->  standard output
revision 1.1
--- cluster/rgmanager/src/resources/postgres-8.metadata
+++ -	2006-09-20 07:14:55.419323000 +0000
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="postgres-8">
+    <version>1.0</version>
+
+    <longdesc lang="en">
+        This defines an instance of PostgreSQL server
+    </longdesc>
+    <shortdesc lang="en">
+        Defines a PostgreSQL server
+    </shortdesc>
+
+    <parameters>
+        <parameter name="name" primary="1">
+	    <longdesc lang="en">
+	        Specifies a service name for logging and other purposes
+	    </longdesc>
+            <shortdesc lang="en">
+                Name
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+        <parameter name="config_file">
+            <longdesc lang="en">
+                Define absolute path to configuration file
+            </longdesc>
+            <shortdesc lang="en">
+                Config File
+            </shortdesc>
+	    <content type="string" default="/var/lib/pgsql/data/postgresql.conf"/>
+        </parameter>
+
+	<parameter name="postmaster_user">
+		<longdesc lang="en">
+			User who runs the database server because it can't be
+			run by root.
+		</longdesc>
+		<shortdesc lang="en">
+			User who runs the database server
+		</shortdesc>
+		<content type="string" default="postgres" />
+	</parameter>
+
+	<parameter name="postmaster_options">
+		<longdesc lang="en">
+			Other command-line options for postmaster
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for postmaster
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+        <parameter name="service_name" inherit="service%name">
+            <longdesc lang="en">
+	    	Inherit the service name.  We need to know
+		the service name in order to determine file
+		systems and IPs for this service.
+            </longdesc>
+            <shortdesc lang="en">
+	    	Inherit the service name.
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+    </parameters>
+
+    <actions>
+        <action name="start" timeout="0"/>
+	<action name="stop" timeout="0"/>
+
+	<!-- Checks to see if it''s mounted in the right place -->
+	<action name="status" interval="1m" timeout="10"/>
+	<action name="monitor" interval="1m" timeout="10"/>
+
+	<!-- Checks to see if we can read from the mountpoint -->
+	<action name="status" depth="10" timeout="30" interval="5m"/>
+	<action name="monitor" depth="10" timeout="30" interval="5m"/>
+
+	<action name="meta-data" timeout="0"/>
+	<action name="verify-all" timeout="0"/>
+    </actions>
+
+    <special tag="rgmanager">
+    </special>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/postgres-8.sh,v  -->  standard output
revision 1.1
--- cluster/rgmanager/src/resources/postgres-8.sh
+++ -	2006-09-20 07:14:55.544445000 +0000
@@ -0,0 +1,217 @@
+#!/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_gen_config_file="/tmp/postgresql.$OCF_RESKEY_name"
+
+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_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
+
+	if [ -e "$PSQL_pid_file" ]; 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"	
+	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
--- cluster/rgmanager/src/resources/utils/ra-skelet.sh	2006/09/18 13:48:07	1.2
+++ cluster/rgmanager/src/resources/utils/ra-skelet.sh	2006/09/20 07:14:55	1.3
@@ -30,7 +30,7 @@
 		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
@@ -49,7 +49,6 @@
 
 	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
 



             reply	other threads:[~2006-09-20  7:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-20  7:14 mgrac [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-11-06 21:25 [Cluster-devel] cluster/rgmanager/src/resources utils/ra-skele mgrac

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=20060920071455.12404.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.