public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: "Fabio M. Di Nitto" <fabbione@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: rgmanager: master - rgmanager: init script rework Date: Tue, 05 May 2009 03:30:00 -0000 [thread overview] Message-ID: <20090505032957.0737212026F@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/rgmanager.git?p=rgmanager.git;a=commitdiff;h=b00c6fb8fb506bedd441730b1e6e7de8bf428a83 Commit: b00c6fb8fb506bedd441730b1e6e7de8bf428a83 Parent: 6f956596e0fb4cffcee95dd84d482a2d7f7ecd7e 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:29:49 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
reply other threads:[~2009-05-05 3:30 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20090505032957.0737212026F@lists.fedorahosted.org \ --to=fabbione@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).