cluster: RHEL6 - cman init: more LSB compliance

Fabio M. Di Nitto fabbione at fedoraproject.org
Fri Jul 9 10:28:28 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=5f5129d0f54fac26b2133afe6f2cad5381fb3114
Commit:        5f5129d0f54fac26b2133afe6f2cad5381fb3114
Parent:        495f1f7c141482bbc3e17b038f7f4078fad3f41f
Author:        Fabio M. Di Nitto <fdinitto at redhat.com>
AuthorDate:    Wed Jul 7 12:15:54 2010 +0200
Committer:     Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Fri Jul 9 12:25:32 2010 +0200

cman init: more LSB compliance

Resolves: rhbz#612097

Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
 cman/init.d/cman.in |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/cman/init.d/cman.in b/cman/init.d/cman.in
index ef0e5ba..9a83c6b 100644
--- a/cman/init.d/cman.in
+++ b/cman/init.d/cman.in
@@ -485,6 +485,7 @@ start_cman()
 		   grep -q Relax-NG $tmpfile ; then
 			cat $tmpfile >&2
 		fi
+		pidof /usr/sbin/corosync > /var/run/cman.pid
 		ret=0
 	fi
 
@@ -511,6 +512,7 @@ stop_cman()
 			sleep 1
 			echo -n "."
 		done
+		rm -f /var/run/cman.pid
 	fi
 	return 0
 }
@@ -783,7 +785,19 @@ stop()
 
 cmanstatus()
 {
-	errmsg=$( status corosync 2>&1 ) || return $?
+	errmsg=$( status corosync 2>&1 )
+	ret=$?
+	if [ "$ret" != "0" ]; then
+		if [ -f /var/run/cman.pid ]; then
+			errmsg="Found stale pid file"
+			return 1
+		fi
+		if [ -f $LOCK_FILE ]; then
+			errmsg="Found stale lock file"
+			return 2
+		fi
+		return $ret
+	fi
 
 	if ! cman_running; then
 		errmsg="cman is not running"
@@ -809,6 +823,11 @@ cmanstatus()
 
 rtrn=0
 
+if [ "$EUID" != "0" ]; then
+	echo "Only root can execute $0 script"
+	exit 4
+fi
+
 # See how we were called.
 case "$1" in
 start)


More information about the cluster-commits mailing list