[Gluster-users] /etc/init.d/glusterfs restart for CentOS

Andrew McGill list2008 at lunch.za.net
Mon Nov 3 08:08:41 UTC 2008


Having looked for it, and not found one, here's a glusterfs init script 
for CentOS/RHEL which I have slapped together with minimal testing.  It 
differs from the ones in 'extras' in the following ways:

  * Starts multiple servers named /etc/glusterfs/*server.vol
  * Mounts client shares listed with -o noauto in /etc/fstab
  * Works on RHAT, which doesn't provide /lib/init/vars.sh

There may be a better way of doing all this.


cat > /etc/init.d/glusterfs << "EOF"
#!/bin/bash
#
#       /etc/rc.d/init.d/glusterfs
#
# Starts the glusterfs client and server daemons
#
# chkconfig: 345 95 5
# description: glusterfs client and server daemons
#    /etc/glusterfs/*server.vol
#    /etc/fstab .*glusterfs.*
# processname: glusterfs

# Source function library.
. /etc/init.d/functions

test -x /usr/sbin/glusterfsd || exit 0

RETVAL=0

#
#       See how we were called.
#

prog="glusterfsd"

start() {
        # Check if glusterfsd is already running
        if [ ! -f /var/lock/subsys/glusterfsd ]; then
            echo -n $"Starting $prog: "
            for CONFIG in /etc/glusterfs/*server.vol ; do
               [ "$CONFIG" = "/etc/glusterfs/*server.vol" ] && continue
               daemon /usr/sbin/glusterfsd -f $CONFIG
            done
            RETVAL=$?

            awk '($3 == "glusterfs" && /noauto/) { print $2 }' < /etc/fstab |
            while read MOUNTPOINT ; do
                mount $MOUNTPOINT
            done

            [ $RETVAL -eq 0 ] && touch /var/lock/subsys/glusterfsd
            echo
        fi
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        awk '($3 == "glusterfs" && /noauto/) { print $2 }' < /etc/fstab |
        while read MOUNTPOINT ; do
            umount -l $MOUNTPOINT
        done
        killproc /usr/sbin/glusterfsd
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/glusterfsd
        echo
        return $RETVAL
}


restart() {
        stop
        start
}

reload() {
        restart
}

status_at() {
        status /usr/sbin/glusterfsd
}

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload|restart)
        restart
        ;;
condrestart)
        if [ -f /var/lock/subsys/glusterfsd ]; then
            restart
        fi
        ;;
status)
        status_at
        ;;
*)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $?
exit $RETVAL




EOF
	




More information about the Gluster-users mailing list