gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gluster-devel] Red Hat init.d Script


From: Anand Avati
Subject: Re: [Gluster-devel] Red Hat init.d Script
Date: Sun, 16 Dec 2007 04:27:36 +0530

Rossi,
 thanks for sharing your script. How would you compare this script against
the one in the source repository? are there features in this which should be
merged into the source repo version?

avati

2007/12/14, Rossi Andrea Modesto <address@hidden>:
>
> Hi All,
>
> i use this script on my RHEL5:
>
> #!/bin/bash
>
> #===============================================================================
> #
> #          FILE:  glusterfsd
> #
> #         USAGE:  service glusterfsd {start|stop|restart|reload}
> #
> #   DESCRIPTION:
> #       OPTIONS:
> #  REQUIREMENTS:  ---
> #          BUGS:  ---
> #         NOTES:  ---
> #        AUTHOR:  Andrea Modesto Rossi, address@hidden
> #       COMPANY:  Spike Reply
> #       LICENSE:  GPL
> #       VERSION:  1.0 rc1
> #       CREATED:  14/12/2007 11:21:27 CEST
> #      REVISION:  ---
>
> #===============================================================================
>
> # Get function from functions library
> #. /etc/rc.d/init.d/functions
>
> LOGGER="/usr/bin/logger"
> BASE=glusterfsd
> GLUSTERFSD="/sbin/$BASE"
> GSERVER="/sbin/$BASE -f /etc/glusterfs/glusterfs-server.vol"
>
>
> function log_fail()
> {
>     echo "FAILED,$1"
> }
>
> getpid()
> {
>        pid=
>        if [ -f /var/run/$BASE.pid ]; then
>                local line p
>                read line < /var/run/$BASE.pid
>                for p in $line ; do
>                        [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid
> $p"
>                done
>        fi
>        if [ -z "$pid" ]; then
>                pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \
>                        pidof -o $$ -o $PPID -o %PPID -x $BASE`
>        fi
> }
>
> # A function to stop gluster
> killgluster()
> {
>        killlevel="-9"
>        getpid
>        if [ ! -z $pid ] ; then
>
>            kill $killlevel $pid
>            if [ "$?" = 0 ]
>                then
>                 echo "Stopping $BASE:                [ OK ]"
>                 $LOGGER -p daemon.info "Gluster process $pid has been
> killed"
>            else
>                 echo "Stopping $BASE:                [ FAILED ]"
>                 $LOGGER -p daemon.error "Failed: Gluster process $pid has
> not been killed"
>           fi
>
>        # Remove pid and lock file if any.
>           if [ -f /var/run/$BASE.pid ] ; then
>                rm -f /var/run/$BASE.pid && logger -p daemon.info "Remove
> $BASE.pid:"
>           else
>                echo "$BASE.pid not found" && logger -p daemon.error"Remove 
> $BASE.pid:"
>           fi
>
>           if [ -f /var/lock/subsys/$BASE ] ; then
>              rm -f /var/lock/subsys/$BASE && logger -p daemon.info "Remove
> $BASE lock file:"
>           else
>              echo "$BASE lock file not found" && logger -p 
> daemon.error"Remove $BASE lock file:"
>          fi
>
>        else
>          echo "Stopping $BASE:          [ FAILED ]"
>        fi
> }
>
> # Start the service $BASE
> start()
> {
>        $LOGGER -p daemon.notice "Starting $BASE:"
>        $GSERVER > /dev/null 2>&1
>        if [ $? = 0 ]
>         then
>           touch /var/lock/subsys/$BASE
>           $LOGGER -p daemon.info "Starting $BASE:               [ OK ]"
>           echo "Starting $BASE:                [ OK ]"
>         else
>           $LOGGER -p daemon.error "Starting $BASE:              [ FAILED
> ]"
>           echo "Starting $BASE:               [ FAILED ]"
>        fi
> }
>
> # Stop the service $BASE
> stop()
> {
>        killgluster
> }
>
> status()
> {
>        getpid
>        if [ -z $pid ] ; then
>           echo "$BASE is stopped."
>        else
>           echo "$BASE is running:               $pid"
>        fi
> }
>
>
> if [ ! -f $LOGGER ] ; then
>     log_fail "cannot find logger"
>     exit 1
> fi
>
> if [ ! -f $GLUSTERFSD ] ; then
>     log_fail "cannot find glusterfsd"
>     exit 1
> fi
>
> case "$1" in
>
>     'start')
>         start
>         ;;
>
>     'stop')
>         stop
>         ;;
>
>     'restart')
>         stop
>         start
>         ;;
>
>     'reload')
>         stop
>         start
>         ;;
>
>     'status')
>         status
>         ;;
>
>     *)
>         echo "Usage: $0 { start | stop | restart | reload | status }"
>         exit 1
>         ;;
> esac
>
> exit 0
>
>
> --------------------------------------------------------------------
> Andrea Modesto Rossi
> Spike Reply S.r.l.
> Via Castellanza, 11 - 20151 Milano
> e-mail address@hidden
> www.reply.it
> --------------------------------------------------------------------
> --------------------------------------------------------------------
>
> --
> The information transmitted is intended for the person or entity to which
> it is addressed and may contain confidential and/or privileged material. Any
> review, retransmission, dissemination or other use of, or taking of any
> action in reliance upon, this information by persons or entities other than
> the intended recipient is prohibited. If you received this in error, please
> contact the sender and delete the material from any computer.
>
>
> _______________________________________________
> Gluster-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/gluster-devel
>



-- 
If I traveled to the end of the rainbow
As Dame Fortune did intend,
Murphy would be there to tell me
The pot's at the other end.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]