public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - rgmanager: init script rework
@ 2009-05-05 3:29 Fabio M. Di Nitto
0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2009-05-05 3:29 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a5b4f05fac4471d0d72470c533e397922086ab03
Commit: a5b4f05fac4471d0d72470c533e397922086ab03
Parent: 26ca8d4ee56576b153075c2ea9ff6f3fff211985
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Tue May 5 05:28:32 2009 +0200
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Tue May 5 05:28:32 2009 +0200
rgmanager: init script rework
- fix white spaces.
- drop old and unrequired log_and_print wrappers
- cleanup stop loop and add comments on it
- stop doing tons of if/else checks in favour of simpler ones
- make the script LSB compliant
- simplify all status/pidof checks
- drop reload operation since it's not required anymore
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
rgmanager/init.d/rgmanager.in | 192 +++++++++++++++--------------------------
1 files changed, 70 insertions(+), 122 deletions(-)
diff --git a/rgmanager/init.d/rgmanager.in b/rgmanager/init.d/rgmanager.in
index 697e66b..0bc1245 100644
--- a/rgmanager/init.d/rgmanager.in
+++ b/rgmanager/init.d/rgmanager.in
@@ -2,7 +2,8 @@
#
# chkconfig: - 99 01
# description: Starts and stops Red Hat Service (resource group) Manager
-
+#
+#
### BEGIN INIT INFO
# Provides: rgmanager
# Required-Start: cman
@@ -13,26 +14,32 @@
# Description: Starts and stops Red Hat Service (resource group) Manager
### END INIT INFO
+ID="Cluster Service Manager"
+RGMGRD="rgmanager"
+
+# set secure PATH
+PATH="/sbin:/bin:/usr/sbin:/usr/bin:@SBINDIR@"
+
success()
{
- echo -ne "[ OK ]\r"
+ echo -ne "[ OK ]\r"
}
failure()
{
- echo -ne "[FAILED]\r"
+ echo -ne "[FAILED]\r"
}
status()
{
- pid=$(pidof $1 2>/dev/null)
- rtrn=$?
- if [ $rtrn -ne 0 ]; then
- echo "$1 is stopped"
- else
- echo "$1 (pid $pid) is running..."
- fi
- return $rtrn
+ pid=$(pidof $1 2>/dev/null)
+ rtrn=$?
+ if [ $rtrn -ne 0 ]; then
+ echo "$1 is stopped"
+ else
+ echo "$1 (pid $pid) is running..."
+ fi
+ return $rtrn
}
# rpm based distros
@@ -50,34 +57,6 @@ if [ -d /etc/default ]; then
[ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/rgmanager"
fi
-PATH=/sbin:/bin:/usr/sbin:/usr/bin:@SBINDIR@
-
-export PATH
-
-ID="Cluster Service Manager"
-RGMGRD="rgmanager"
-
-LOG_ERR=3
-LOG_WARNING=4
-LOG_NOTICE=5
-LOG_INFO=6
-
-#
-# log_and_print <level> <message>
-#
-log_and_print()
-{
- if [ -z "$1" -o -z "$2" ]; then
- return 1;
- fi
-
- clulog -s $1 "$2"
- echo -n $2
-
- return 0;
-}
-
-
#
# Bring down the cluster on a node.
#
@@ -85,102 +64,71 @@ stop_cluster()
{
kill -TERM $(pidof $RGMGRD)
- while [ 0 ]; do
-
- if [ -n "$(pidof $RGMGRD)" ]; then
- echo -n "Waiting for services to stop: "
- while [ -n "`pidof $RGMGRD`" ]; do
- sleep 1
- done
- success
- echo
- else
- echo "Services are stopped."
- fi
-
- # Ensure all NFS rmtab daemons are dead.
- killall $RMTABD > /dev/null 2>&1
-
- rm -f /var/run/$RGMGRD.pid
-
- return 0
+ # this unbreakable loop is meant to be done this way.
+ # there are resources that can take up to several minutes
+ # to stop and there is no "right timeout".
+ while status $RGMGRD > /dev/null 2>&1; do
+ sleep 1
done
}
+rtrn=0
-case $1 in
- start)
- echo -n "Starting $ID: "
+case "$1" in
+start)
+ echo -n "Starting $ID: "
- # most recent distributions use tmpfs for /var/run
- # to avoid to clean it up on every boot.
- # they also assume that init scripts will create
- # required subdirectories for proper operations
- mkdir -p /var/run/cluster
+ # most recent distributions use tmpfs for /var/run
+ # to avoid to clean it up on every boot.
+ # they also assume that init scripts will create
+ # required subdirectories for proper operations
+ mkdir -p /var/run/cluster
- $RGMGRD $RGMGR_OPTS
- rtrn=$?
- if [ $rtrn = 0 ]; then
- touch $LOCK_FILE
+ if status $RGMGRD > /dev/null 2>&1; then
+ success
+ else
+ if $RGMGRD $RGMGR_OPTS; then
success
else
failure
+ rtrn=1
fi
- echo
-
- exit $rtrn
- ;;
-
- restart)
- $0 status > /dev/null 2>&1
- if [ $? -ne 1 ]; then
- $0 stop
- fi
- $0 start
- ;;
-
- condrestart)
- $0 status > /dev/null 2>&1
- if [ $? -eq 0 ]; then
- $0 stop
- $0 start
- fi
- ;;
-
- reload)
- log_and_print $LOG_NOTICE "Reloading Resource Configuration."
- kill -HUP $(pidof $RGMGRD) 2>&1
- rtrn=$?
- if [ $rtrn = 0 ]; then
+ fi
+ echo
+;;
+restart|condrestart)
+ $0 stop
+ $0 start
+;;
+reload)
+ # not required anymore
+ # return not implemented
+ rtrn=3
+;;
+status)
+ status $RGMGRD
+ rtrn=$?
+;;
+stop)
+ echo -n "Stopping $ID: "
+
+ if status $RGMGRD > /dev/null 2>&1; then
+ if stop_cluster; then
success
else
failure
+ rtrn=1
fi
- echo
-
- exit $rtrn
- ;;
-
- status)
- status $RGMGRD
- exit $?
- ;;
-
- stop)
- if [ -n "$(pidof $RGMGRD)" ]; then
- log_and_print $LOG_NOTICE "Shutting down $ID..."
- echo
- stop_cluster
- fi
-
- rm -f $LOCK_FILE
- log_and_print $LOG_NOTICE "$ID is stopped."
- echo
- ;;
- *)
- echo "usage: $0 {start|restart|condrestart|reload|status|stop}"
- exit 1
- ;;
+ else
+ success
+ fi
+ echo
+ rm -f $LOCK_FILE
+;;
+*)
+ echo "usage: $0 {start|restart|condrestart|reload|status|stop}"
+ rtrn=1
+;;
esac
-exit 0
+exit $rtrn
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-05 3:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-05 3:29 cluster: STABLE3 - rgmanager: init script rework Fabio M. Di Nitto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).