This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE3 - cman init: more cleanup


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ddffd05beeb88b79a42adf1beee4f15dff155c54
Commit:        ddffd05beeb88b79a42adf1beee4f15dff155c54
Parent:        bac9a4aa90acea30ce8e265103c315b1b25a451e
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Wed Mar 25 10:56:48 2009 +0100
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Fri Mar 27 20:05:45 2009 +0100

cman init: more cleanup

Add ok/nok local functions to print/return status.

Simplify unfence_self function and make it a bit more verbose.

Fix another couple of whitespace bits.

Use ok/nok where possible.

default rtrn code to 0 and change it on failure.

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

diff --git a/cman/init.d/cman.in b/cman/init.d/cman.in
index 79059b3..ebb6b64 100644
--- a/cman/init.d/cman.in
+++ b/cman/init.d/cman.in
@@ -138,6 +138,17 @@ fi
 # openaisparser   - use internal openais config file parser.
 [ -n "$CONFIG_LOADER" ] && cman_join_opts+=" -C $CONFIG_LOADER"
 
+ok() {
+	success
+	echo
+}
+
+nok() {
+	failure
+	echo
+	return 1
+}
+
 load_modules()
 {
 	errmsg=$( /sbin/modprobe configfs 2>&1 ) || return 1
@@ -199,20 +210,23 @@ start_cman()
 
 unfence_self()
 {
+	echo -n "   Unfencing self... "
 	fence_node -U > /dev/null 2>&1
-	error=$?
 
-	if [ $error -eq 0 ]; then
-		echo "   Unfencing self... done"
-		return 0
-	else
-		if [ $error -eq 1 ]; then
-			echo "   Unfencing self... failed"
+	case $? in
+		0)
+			ok
+		;;
+		1)
+			nok
 			return 1
-		else
-			return 0
-		fi
-	fi
+		;;
+		2)
+			echo -n "unconfigured"
+			ok
+		;;
+	esac
+	return 0
 }
 
 start_qdiskd()
@@ -224,7 +238,6 @@ start_qdiskd()
 	return 0
 }
 
-
 start_daemons()
 {
 	if ! status groupd > /dev/null 2>&1 && \
@@ -258,8 +271,8 @@ start_daemons()
 			return 1
 		;;
 		esac
-    fi
-    return 0
+	fi
+	return 0
 }
 
 start_fence()
@@ -402,82 +415,71 @@ start()
 	if xend_bridged_net_enabled; then
 		echo -n "   Enabling workaround for Xend bridged networking... "
 		if xend_bridged_net_start; then
-			echo "done"
+			ok
 		else
-			echo "failed: $errmsg"
-			return 1
+			nok
 		fi
 	fi
 
 	echo -n "   Loading modules... "
 	if load_modules; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	echo -n "   Mounting configfs... "
 	if start_configfs; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi	
 
 	echo -n "   Setting network parameters... "
-	set_networking_params
 	if set_networking_params; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	echo -n "   Starting cman... "
-	start_cman
 	if start_cman; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	unfence_self || return 1
 
 	echo -n "   Starting qdiskd... "
 	if start_qdiskd; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	echo -n "   Starting daemons... "
 	if start_daemons; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	if fence_join_enabled; then
 		echo -n "   Starting fencing... "
 		if start_fence; then
-			echo "done"
+			ok
 		else
-			echo "failed"
-			return 1
+			nok
 		fi
 	fi
 
 	if fence_xvmd_enabled; then
 		echo -n "   Starting virtual machine fencing host... "
 		if start_fence_xvmd; then
-			echo "done"
+			ok
 		else
-			echo "failed"
-			return 1
+			nok
 		fi
 	fi
     
@@ -573,61 +575,54 @@ stop()
 	if fence_xvmd_enabled; then
 		echo -n "   Stopping virtual machine fencing host... "
 		if stop_fence_xvmd; then
-			echo "done"
+			ok
 		else
-			echo "failed"
-			return 1
+			nok
 		fi
 	fi
 
 	if fence_join_enabled; then
 		echo -n "   Stopping fencing... "
 		if stop_fence; then
-			echo "done"
+			ok
 		else
-			echo "failed"
-			return 1
+			nok
 		fi
 	fi
 
 	echo -n "   Stopping daemons... "
 	if stop_daemons; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	echo -n "   Stopping the Quorum Disk Daemon: "
 	if stop_qdiskd; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	echo -n "   Stopping cman... "
 	if stop_cman "$1"; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	echo -n "   Stopping cmannotifyd... "
 	if stop_cmannotifyd; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	echo -n "   Unmounting configfs... "
 	if stop_configfs; then
-		echo "done"
+		ok
 	else
-		echo "failed"
-		return 1
+		nok
 	fi
 
 	return 0
@@ -669,53 +664,47 @@ cmanstatus()
 	return 0
 }
 
-rtrn=1
+rtrn=0
 
 # See how we were called.
 case "$1" in
 start)
 	if start; then
 		touch $LOCK_FILE
-		success
-		rtrn=0
 	else
 		echo $errmsg
-		failure 
+		rtrn=1
 	fi
-	echo
 ;;
 stop)
 	if stop; then
-		success
 		rm -f $LOCK_FILE
-		rtrn=0
 	else
 		echo $errmsg
-		failure
+		rtrn=1
 	fi
-	echo
 ;;
 restart|reload)
 	echo -n "Restarting cluster: "
 	if stop remove > /dev/null 2>&1 && \
 		start > /dev/null 2>&1; then
-			success
-			rtrn=0
+			ok
 	else
 		failure
+		rtrn=1
 	fi
-	echo
 ;;
 status)
 	if cmanstatus; then
-		echo "cman is running."
-		rtrn=0
+		echo "cluster is running."
 	else
 		echo $errmsg
+		rtrn=1
 	fi
 ;;
 *)
 	echo "Usage: $0 {start|stop|reload|restart|status}"
+	rtrn=1
 ;;
 esac
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]