summaryrefslogtreecommitdiffstats
path: root/extras/hook-scripts/reset/post/S31ganesha-reset.sh
blob: c0be3f3841d3af876dc79e3d2a520cf1240fef24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#/bin/bash
PROGNAME="Sganesha-reset"
OPTSPEC="volname:,gd-workdir:"
VOL=
GLUSTERD_WORKDIR=

function parse_args () {
        ARGS=$(getopt -l $OPTSPEC  -o "o" -name $PROGNAME $@)
        eval set -- "$ARGS"
        while true; do
            case $1 in
                --volname)
                    shift
                    VOL=$1
                    ;;
                --gd-workdir)
                    shift
                    GLUSTERD_WORKDIR=$1
                    ;;
            esac
            shift
        done
}

function is_volume_started () {
        volname=$1
        echo "$(grep status $GLUSTERD_WORKDIR/vols/"$volname"/info |\
                cut -d"=" -f2)"
}

parse_args $@
if ps auxwww | grep -q "[g]anesha.nfsd"
        then
        kill -s TERM `cat /var/run/ganesha.pid`
        sleep 10
        rm -rf /var/lib/glusterfs-ganesha/exports
        rm -rf /var/lib/glusterfs-ganesha/.export_added
        sed -i /conf/d /var/lib/ganesha/nfs-ganesha.conf
        if [ "1" = $(is_volume_started "$VOL") ];
                then
                gluster volume start $VOL force
        fi
fi