14f8ab
From 1fb89973551937f34f24b45e07072a6ce6c30ff9 Mon Sep 17 00:00:00 2001
14f8ab
From: Jiffin Tony Thottan <jthottan@redhat.com>
14f8ab
Date: Mon, 16 Oct 2017 14:18:31 +0530
14f8ab
Subject: [PATCH 053/124] Revert "packaging: (ganesha) remove glusterfs-ganesha
14f8ab
 subpackage and related files)"
14f8ab
14f8ab
This reverts commit 0cf2963f12a8b540a7042605d8c79f638fdf6cee.
14f8ab
14f8ab
Label: DOWNSTREAM ONLY
14f8ab
14f8ab
Change-Id: Id6e7585021bd4dd78a59580cfa4838bdd4e539a0
14f8ab
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/167102
14f8ab
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 configure.ac                                       |   3 +
14f8ab
 extras/Makefile.am                                 |   3 +-
14f8ab
 extras/ganesha/Makefile.am                         |   2 +
14f8ab
 extras/ganesha/config/Makefile.am                  |   4 +
14f8ab
 extras/ganesha/config/ganesha-ha.conf.sample       |  19 ++++
14f8ab
 extras/ganesha/scripts/Makefile.am                 |   4 +
14f8ab
 extras/ganesha/scripts/create-export-ganesha.sh    |  91 +++++++++++++++
14f8ab
 extras/ganesha/scripts/dbus-send.sh                |  60 ++++++++++
14f8ab
 extras/ganesha/scripts/generate-epoch.py           |  48 ++++++++
14f8ab
 extras/hook-scripts/start/post/Makefile.am         |   2 +-
14f8ab
 extras/hook-scripts/start/post/S31ganesha-start.sh | 122 +++++++++++++++++++++
14f8ab
 glusterfs.spec.in                                  |  44 +++++++-
14f8ab
 12 files changed, 396 insertions(+), 6 deletions(-)
14f8ab
 create mode 100644 extras/ganesha/Makefile.am
14f8ab
 create mode 100644 extras/ganesha/config/Makefile.am
14f8ab
 create mode 100644 extras/ganesha/config/ganesha-ha.conf.sample
14f8ab
 create mode 100644 extras/ganesha/scripts/Makefile.am
14f8ab
 create mode 100755 extras/ganesha/scripts/create-export-ganesha.sh
14f8ab
 create mode 100755 extras/ganesha/scripts/dbus-send.sh
14f8ab
 create mode 100755 extras/ganesha/scripts/generate-epoch.py
14f8ab
 create mode 100755 extras/hook-scripts/start/post/S31ganesha-start.sh
14f8ab
14f8ab
diff --git a/configure.ac b/configure.ac
14f8ab
index 0d06f5a..125ae29 100644
14f8ab
--- a/configure.ac
14f8ab
+++ b/configure.ac
14f8ab
@@ -196,6 +196,9 @@ AC_CONFIG_FILES([Makefile
14f8ab
                 extras/init.d/glustereventsd-Debian
14f8ab
                 extras/init.d/glustereventsd-Redhat
14f8ab
                 extras/init.d/glustereventsd-FreeBSD
14f8ab
+                extras/ganesha/Makefile
14f8ab
+                extras/ganesha/config/Makefile
14f8ab
+                extras/ganesha/scripts/Makefile
14f8ab
                 extras/systemd/Makefile
14f8ab
                 extras/systemd/glusterd.service
14f8ab
                 extras/systemd/glustereventsd.service
14f8ab
diff --git a/extras/Makefile.am b/extras/Makefile.am
14f8ab
index ff5ca9b..983f014 100644
14f8ab
--- a/extras/Makefile.am
14f8ab
+++ b/extras/Makefile.am
14f8ab
@@ -11,7 +11,8 @@ EditorModedir = $(docdir)
14f8ab
 EditorMode_DATA = glusterfs-mode.el glusterfs.vim
14f8ab
 
14f8ab
 SUBDIRS = init.d systemd benchmarking hook-scripts $(OCF_SUBDIR) LinuxRPM \
14f8ab
-          $(GEOREP_EXTRAS_SUBDIR) snap_scheduler firewalld cliutils python
14f8ab
+          $(GEOREP_EXTRAS_SUBDIR) snap_scheduler firewalld cliutils python \
14f8ab
+		  ganesha
14f8ab
 
14f8ab
 confdir = $(sysconfdir)/glusterfs
14f8ab
 if WITH_SERVER
14f8ab
diff --git a/extras/ganesha/Makefile.am b/extras/ganesha/Makefile.am
14f8ab
new file mode 100644
14f8ab
index 0000000..542de68
14f8ab
--- /dev/null
14f8ab
+++ b/extras/ganesha/Makefile.am
14f8ab
@@ -0,0 +1,2 @@
14f8ab
+SUBDIRS = scripts config
14f8ab
+CLEANFILES =
14f8ab
diff --git a/extras/ganesha/config/Makefile.am b/extras/ganesha/config/Makefile.am
14f8ab
new file mode 100644
14f8ab
index 0000000..c729273
14f8ab
--- /dev/null
14f8ab
+++ b/extras/ganesha/config/Makefile.am
14f8ab
@@ -0,0 +1,4 @@
14f8ab
+EXTRA_DIST= ganesha-ha.conf.sample
14f8ab
+
14f8ab
+confdir = $(sysconfdir)/ganesha
14f8ab
+conf_DATA = ganesha-ha.conf.sample
14f8ab
diff --git a/extras/ganesha/config/ganesha-ha.conf.sample b/extras/ganesha/config/ganesha-ha.conf.sample
14f8ab
new file mode 100644
14f8ab
index 0000000..c22892b
14f8ab
--- /dev/null
14f8ab
+++ b/extras/ganesha/config/ganesha-ha.conf.sample
14f8ab
@@ -0,0 +1,19 @@
14f8ab
+# Name of the HA cluster created.
14f8ab
+# must be unique within the subnet
14f8ab
+HA_NAME="ganesha-ha-360"
14f8ab
+#
14f8ab
+# N.B. you may use short names or long names; you may not use IP addrs.
14f8ab
+# Once you select one, stay with it as it will be mildly unpleasant to
14f8ab
+# clean up if you switch later on. Ensure that all names - short and/or
14f8ab
+# long - are in DNS or /etc/hosts on all machines in the cluster.
14f8ab
+#
14f8ab
+# The subset of nodes of the Gluster Trusted Pool that form the ganesha
14f8ab
+# HA cluster. Hostname is specified.
14f8ab
+HA_CLUSTER_NODES="server1,server2,..."
14f8ab
+#HA_CLUSTER_NODES="server1.lab.redhat.com,server2.lab.redhat.com,..."
14f8ab
+#
14f8ab
+# Virtual IPs for each of the nodes specified above.
14f8ab
+VIP_server1="10.0.2.1"
14f8ab
+VIP_server2="10.0.2.2"
14f8ab
+#VIP_server1_lab_redhat_com="10.0.2.1"
14f8ab
+#VIP_server2_lab_redhat_com="10.0.2.2"
14f8ab
diff --git a/extras/ganesha/scripts/Makefile.am b/extras/ganesha/scripts/Makefile.am
14f8ab
new file mode 100644
14f8ab
index 0000000..00a2c45
14f8ab
--- /dev/null
14f8ab
+++ b/extras/ganesha/scripts/Makefile.am
14f8ab
@@ -0,0 +1,4 @@
14f8ab
+EXTRA_DIST= create-export-ganesha.sh generate-epoch.py dbus-send.sh
14f8ab
+
14f8ab
+scriptsdir = $(libexecdir)/ganesha
14f8ab
+scripts_SCRIPTS = create-export-ganesha.sh dbus-send.sh generate-epoch.py
14f8ab
diff --git a/extras/ganesha/scripts/create-export-ganesha.sh b/extras/ganesha/scripts/create-export-ganesha.sh
14f8ab
new file mode 100755
14f8ab
index 0000000..1ffba42
14f8ab
--- /dev/null
14f8ab
+++ b/extras/ganesha/scripts/create-export-ganesha.sh
14f8ab
@@ -0,0 +1,91 @@
14f8ab
+#!/bin/bash
14f8ab
+
14f8ab
+#This script is called by glusterd when the user
14f8ab
+#tries to export a volume via NFS-Ganesha.
14f8ab
+#An export file specific to a volume
14f8ab
+#is created in GANESHA_DIR/exports.
14f8ab
+
14f8ab
+# Try loading the config from any of the distro
14f8ab
+# specific configuration locations
14f8ab
+if [ -f /etc/sysconfig/ganesha ]
14f8ab
+        then
14f8ab
+        . /etc/sysconfig/ganesha
14f8ab
+fi
14f8ab
+if [ -f /etc/conf.d/ganesha ]
14f8ab
+        then
14f8ab
+        . /etc/conf.d/ganesha
14f8ab
+fi
14f8ab
+if [ -f /etc/default/ganesha ]
14f8ab
+        then
14f8ab
+        . /etc/default/ganesha
14f8ab
+fi
14f8ab
+
14f8ab
+GANESHA_DIR=${1%/}
14f8ab
+OPTION=$2
14f8ab
+VOL=$3
14f8ab
+CONF=$GANESHA_DIR"/ganesha.conf"
14f8ab
+declare -i EXPORT_ID
14f8ab
+
14f8ab
+function check_cmd_status()
14f8ab
+{
14f8ab
+        if [ "$1" != "0" ]
14f8ab
+                 then
14f8ab
+                 rm -rf $GANESHA_DIR/exports/export.$VOL.conf
14f8ab
+                 sed -i /$VOL.conf/d $CONF
14f8ab
+                 exit 1
14f8ab
+        fi
14f8ab
+}
14f8ab
+
14f8ab
+
14f8ab
+if [ ! -d "$GANESHA_DIR/exports" ];
14f8ab
+        then
14f8ab
+        mkdir $GANESHA_DIR/exports
14f8ab
+        check_cmd_status `echo $?`
14f8ab
+fi
14f8ab
+
14f8ab
+function write_conf()
14f8ab
+{
14f8ab
+echo -e "# WARNING : Using Gluster CLI will overwrite manual
14f8ab
+# changes made to this file. To avoid it, edit the
14f8ab
+# file and run ganesha-ha.sh --refresh-config."
14f8ab
+
14f8ab
+echo "EXPORT{"
14f8ab
+echo "      Export_Id = 2;"
14f8ab
+echo "      Path = \"/$VOL\";"
14f8ab
+echo "      FSAL {"
14f8ab
+echo "           name = "GLUSTER";"
14f8ab
+echo "           hostname=\"localhost\";"
14f8ab
+echo  "          volume=\"$VOL\";"
14f8ab
+echo "           }"
14f8ab
+echo "      Access_type = RW;"
14f8ab
+echo "      Disable_ACL = true;"
14f8ab
+echo '      Squash="No_root_squash";'
14f8ab
+echo "      Pseudo=\"/$VOL\";"
14f8ab
+echo '      Protocols = "3", "4" ;'
14f8ab
+echo '      Transports = "UDP","TCP";'
14f8ab
+echo '      SecType = "sys";'
14f8ab
+echo "     }"
14f8ab
+}
14f8ab
+if [ "$OPTION" = "on" ];
14f8ab
+then
14f8ab
+        if ! (cat $CONF | grep  $VOL.conf\"$ )
14f8ab
+        then
14f8ab
+                write_conf $@ > $GANESHA_DIR/exports/export.$VOL.conf
14f8ab
+                echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF
14f8ab
+                count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l`
14f8ab
+                if [ "$count" = "1" ] ; then
14f8ab
+                        EXPORT_ID=2
14f8ab
+                else
14f8ab
+                        EXPORT_ID=`cat $GANESHA_DIR/.export_added`
14f8ab
+                        check_cmd_status `echo $?`
14f8ab
+                        EXPORT_ID=EXPORT_ID+1
14f8ab
+                        sed -i s/Export_Id.*/"Export_Id= $EXPORT_ID ;"/ \
14f8ab
+                        $GANESHA_DIR/exports/export.$VOL.conf
14f8ab
+                        check_cmd_status `echo $?`
14f8ab
+                fi
14f8ab
+                echo $EXPORT_ID > $GANESHA_DIR/.export_added
14f8ab
+        fi
14f8ab
+else
14f8ab
+        rm -rf $GANESHA_DIR/exports/export.$VOL.conf
14f8ab
+        sed -i /$VOL.conf/d $CONF
14f8ab
+fi
14f8ab
diff --git a/extras/ganesha/scripts/dbus-send.sh b/extras/ganesha/scripts/dbus-send.sh
14f8ab
new file mode 100755
14f8ab
index 0000000..ec8d948
14f8ab
--- /dev/null
14f8ab
+++ b/extras/ganesha/scripts/dbus-send.sh
14f8ab
@@ -0,0 +1,60 @@
14f8ab
+#!/bin/bash
14f8ab
+
14f8ab
+# Try loading the config from any of the distro
14f8ab
+# specific configuration locations
14f8ab
+if [ -f /etc/sysconfig/ganesha ]
14f8ab
+        then
14f8ab
+        . /etc/sysconfig/ganesha
14f8ab
+fi
14f8ab
+if [ -f /etc/conf.d/ganesha ]
14f8ab
+        then
14f8ab
+        . /etc/conf.d/ganesha
14f8ab
+fi
14f8ab
+if [ -f /etc/default/ganesha ]
14f8ab
+        then
14f8ab
+        . /etc/default/ganesha
14f8ab
+fi
14f8ab
+
14f8ab
+GANESHA_DIR=${1%/}
14f8ab
+OPTION=$2
14f8ab
+VOL=$3
14f8ab
+CONF=$GANESHA_DIR"/ganesha.conf"
14f8ab
+
14f8ab
+function check_cmd_status()
14f8ab
+{
14f8ab
+        if [ "$1" != "0" ]
14f8ab
+        then
14f8ab
+                logger "dynamic export failed on node :${hostname -s}"
14f8ab
+        fi
14f8ab
+}
14f8ab
+
14f8ab
+#This function keeps track of export IDs and increments it with every new entry
14f8ab
+function dynamic_export_add()
14f8ab
+{
14f8ab
+        dbus-send  --system \
14f8ab
+--dest=org.ganesha.nfsd  /org/ganesha/nfsd/ExportMgr \
14f8ab
+org.ganesha.nfsd.exportmgr.AddExport  string:$GANESHA_DIR/exports/export.$VOL.conf \
14f8ab
+string:"EXPORT(Path=/$VOL)"
14f8ab
+        check_cmd_status `echo $?`
14f8ab
+}
14f8ab
+
14f8ab
+#This function removes an export dynamically(uses the export_id of the export)
14f8ab
+function dynamic_export_remove()
14f8ab
+{
14f8ab
+        removed_id=`cat $GANESHA_DIR/exports/export.$VOL.conf |\
14f8ab
+grep Export_Id | awk -F"[=,;]" '{print$2}'| tr -d '[[:space:]]'`
14f8ab
+        dbus-send --print-reply --system \
14f8ab
+--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
14f8ab
+org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id
14f8ab
+        check_cmd_status `echo $?`
14f8ab
+}
14f8ab
+
14f8ab
+if [ "$OPTION" = "on" ];
14f8ab
+then
14f8ab
+        dynamic_export_add $@
14f8ab
+fi
14f8ab
+
14f8ab
+if [ "$OPTION" = "off" ];
14f8ab
+then
14f8ab
+        dynamic_export_remove $@
14f8ab
+fi
14f8ab
diff --git a/extras/ganesha/scripts/generate-epoch.py b/extras/ganesha/scripts/generate-epoch.py
14f8ab
new file mode 100755
14f8ab
index 0000000..5db5e56
14f8ab
--- /dev/null
14f8ab
+++ b/extras/ganesha/scripts/generate-epoch.py
14f8ab
@@ -0,0 +1,48 @@
14f8ab
+#!/usr/bin/python
14f8ab
+#
14f8ab
+# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
14f8ab
+# This file is part of GlusterFS.
14f8ab
+#
14f8ab
+# This file is licensed to you under your choice of the GNU Lesser
14f8ab
+# General Public License, version 3 or any later version (LGPLv3 or
14f8ab
+# later), or the GNU General Public License, version 2 (GPLv2), in all
14f8ab
+# cases as published by the Free Software Foundation.
14f8ab
+#
14f8ab
+# Generates unique epoch value on each gluster node to be used by
14f8ab
+# nfs-ganesha service on that node.
14f8ab
+#
14f8ab
+# Configure 'EPOCH_EXEC' option to this script path in
14f8ab
+# '/etc/sysconfig/ganesha' file used by nfs-ganesha service.
14f8ab
+#
14f8ab
+# Construct epoch as follows -
14f8ab
+#        first 32-bit contains the now() time
14f8ab
+#        rest 32-bit value contains the local glusterd node uuid
14f8ab
+
14f8ab
+import time
14f8ab
+import binascii
14f8ab
+
14f8ab
+# Calculate the now() time into a 64-bit integer value
14f8ab
+def epoch_now():
14f8ab
+        epoch_time = int(time.mktime(time.localtime())) << 32
14f8ab
+        return epoch_time
14f8ab
+
14f8ab
+# Read glusterd UUID and extract first 32-bit of it
14f8ab
+def epoch_uuid():
14f8ab
+        file_name = '/var/lib/glusterd/glusterd.info'
14f8ab
+
14f8ab
+        for line in open(file_name):
14f8ab
+                if "UUID" in line:
14f8ab
+                        glusterd_uuid = line.split('=')[1].strip()
14f8ab
+
14f8ab
+        uuid_bin = binascii.unhexlify(glusterd_uuid.replace("-",""))
14f8ab
+
14f8ab
+        epoch_uuid = int(uuid_bin.encode('hex'), 32) & 0xFFFF0000
14f8ab
+        return epoch_uuid
14f8ab
+
14f8ab
+# Construct epoch as follows -
14f8ab
+#        first 32-bit contains the now() time
14f8ab
+#        rest 32-bit value contains the local glusterd node uuid
14f8ab
+epoch = (epoch_now() | epoch_uuid())
14f8ab
+print str(epoch)
14f8ab
+
14f8ab
+exit(0)
14f8ab
diff --git a/extras/hook-scripts/start/post/Makefile.am b/extras/hook-scripts/start/post/Makefile.am
14f8ab
index e32546d..792019d 100644
14f8ab
--- a/extras/hook-scripts/start/post/Makefile.am
14f8ab
+++ b/extras/hook-scripts/start/post/Makefile.am
14f8ab
@@ -1,4 +1,4 @@
14f8ab
-EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh
14f8ab
+EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh S31ganesha-start.sh
14f8ab
 
14f8ab
 hookdir = $(GLUSTERD_WORKDIR)/hooks/1/start/post/
14f8ab
 if WITH_SERVER
14f8ab
diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh
14f8ab
new file mode 100755
14f8ab
index 0000000..90ba6bc
14f8ab
--- /dev/null
14f8ab
+++ b/extras/hook-scripts/start/post/S31ganesha-start.sh
14f8ab
@@ -0,0 +1,122 @@
14f8ab
+#!/bin/bash
14f8ab
+PROGNAME="Sganesha-start"
14f8ab
+OPTSPEC="volname:,gd-workdir:"
14f8ab
+VOL=
14f8ab
+declare -i EXPORT_ID
14f8ab
+ganesha_key="ganesha.enable"
14f8ab
+GANESHA_DIR="/var/run/gluster/shared_storage/nfs-ganesha"
14f8ab
+CONF1="$GANESHA_DIR/ganesha.conf"
14f8ab
+GLUSTERD_WORKDIR=
14f8ab
+
14f8ab
+function parse_args ()
14f8ab
+{
14f8ab
+        ARGS=$(getopt -l $OPTSPEC  -o "o" -name $PROGNAME $@)
14f8ab
+        eval set -- "$ARGS"
14f8ab
+
14f8ab
+        while true; do
14f8ab
+            case $1 in
14f8ab
+                --volname)
14f8ab
+                    shift
14f8ab
+                    VOL=$1
14f8ab
+                    ;;
14f8ab
+                --gd-workdir)
14f8ab
+                    shift
14f8ab
+                    GLUSTERD_WORKDIR=$1
14f8ab
+                    ;;
14f8ab
+                *)
14f8ab
+                    shift
14f8ab
+                    break
14f8ab
+                    ;;
14f8ab
+            esac
14f8ab
+            shift
14f8ab
+        done
14f8ab
+}
14f8ab
+
14f8ab
+
14f8ab
+
14f8ab
+#This function generates a new export entry as export.volume_name.conf
14f8ab
+function write_conf()
14f8ab
+{
14f8ab
+echo -e "# WARNING : Using Gluster CLI will overwrite manual
14f8ab
+# changes made to this file. To avoid it, edit the
14f8ab
+# file, copy it over to all the NFS-Ganesha nodes
14f8ab
+# and run ganesha-ha.sh --refresh-config."
14f8ab
+
14f8ab
+echo "EXPORT{"
14f8ab
+echo "      Export_Id = 2;"
14f8ab
+echo "      Path = \"/$VOL\";"
14f8ab
+echo "      FSAL {"
14f8ab
+echo "           name = \"GLUSTER\";"
14f8ab
+echo "           hostname=\"localhost\";"
14f8ab
+echo "           volume=\"$VOL\";"
14f8ab
+echo "           }"
14f8ab
+echo "      Access_type = RW;"
14f8ab
+echo "      Disable_ACL = true;"
14f8ab
+echo "      Squash=\"No_root_squash\";"
14f8ab
+echo "      Pseudo=\"/$VOL\";"
14f8ab
+echo "      Protocols = \"3\", \"4\" ;"
14f8ab
+echo "      Transports = \"UDP\",\"TCP\";"
14f8ab
+echo "      SecType = \"sys\";"
14f8ab
+echo "}"
14f8ab
+}
14f8ab
+
14f8ab
+#It adds the export dynamically by sending dbus signals
14f8ab
+function export_add()
14f8ab
+{
14f8ab
+        dbus-send --print-reply --system --dest=org.ganesha.nfsd \
14f8ab
+/org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.AddExport \
14f8ab
+string:$GANESHA_DIR/exports/export.$VOL.conf string:"EXPORT(Export_Id=$EXPORT_ID)"
14f8ab
+
14f8ab
+}
14f8ab
+
14f8ab
+# based on src/scripts/ganeshactl/Ganesha/export_mgr.py
14f8ab
+function is_exported()
14f8ab
+{
14f8ab
+        local volume="${1}"
14f8ab
+
14f8ab
+        dbus-send --type=method_call --print-reply --system \
14f8ab
+                  --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
14f8ab
+                  org.ganesha.nfsd.exportmgr.ShowExports \
14f8ab
+            | grep -w -q "/${volume}"
14f8ab
+
14f8ab
+        return $?
14f8ab
+}
14f8ab
+
14f8ab
+# Check the info file (contains the volume options) to see if Ganesha is
14f8ab
+# enabled for this volume.
14f8ab
+function ganesha_enabled()
14f8ab
+{
14f8ab
+        local volume="${1}"
14f8ab
+        local info_file="${GLUSTERD_WORKDIR}/vols/${VOL}/info"
14f8ab
+        local enabled="off"
14f8ab
+
14f8ab
+        enabled=$(grep -w ${ganesha_key} ${info_file} | cut -d"=" -f2)
14f8ab
+
14f8ab
+        [ "${enabled}" == "on" ]
14f8ab
+
14f8ab
+        return $?
14f8ab
+}
14f8ab
+
14f8ab
+parse_args $@
14f8ab
+
14f8ab
+if ganesha_enabled ${VOL} && ! is_exported ${VOL}
14f8ab
+then
14f8ab
+        if [ ! -e ${GANESHA_DIR}/exports/export.${VOL}.conf ]
14f8ab
+        then
14f8ab
+                #Remove export entry from nfs-ganesha.conf
14f8ab
+                sed -i /$VOL.conf/d  $CONF1
14f8ab
+                write_conf ${VOL} > ${GANESHA_DIR}/exports/export.${VOL}.conf
14f8ab
+                EXPORT_ID=`cat $GANESHA_DIR/.export_added`
14f8ab
+                EXPORT_ID=EXPORT_ID+1
14f8ab
+                echo $EXPORT_ID > $GANESHA_DIR/.export_added
14f8ab
+                sed -i s/Export_Id.*/"Export_Id=$EXPORT_ID;"/ \
14f8ab
+                        $GANESHA_DIR/exports/export.$VOL.conf
14f8ab
+                echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF1
14f8ab
+        else
14f8ab
+                EXPORT_ID=$(grep ^[[:space:]]*Export_Id $GANESHA_DIR/exports/export.$VOL.conf |\
14f8ab
+                          awk -F"[=,;]" '{print $2}' | tr -d '[[:space:]]')
14f8ab
+        fi
14f8ab
+        export_add $VOL
14f8ab
+fi
14f8ab
+
14f8ab
+exit 0
14f8ab
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
14f8ab
index 0d57b49..dd7438c 100644
14f8ab
--- a/glusterfs.spec.in
14f8ab
+++ b/glusterfs.spec.in
14f8ab
@@ -299,7 +299,6 @@ Obsoletes:        hekafs
14f8ab
 Obsoletes:        %{name}-common < %{version}-%{release}
14f8ab
 Obsoletes:        %{name}-core < %{version}-%{release}
14f8ab
 Obsoletes:        %{name}-ufo
14f8ab
-Obsoletes:        %{name}-ganesha
14f8ab
 %if ( 0%{!?_with_gnfs:1} )
14f8ab
 Obsoletes:        %{name}-gnfs
14f8ab
 %endif
14f8ab
@@ -455,6 +454,30 @@ is in user space and easily manageable.
14f8ab
 This package provides support to FUSE based clients and inlcudes the
14f8ab
 glusterfs(d) binary.
14f8ab
 
14f8ab
+%if ( 0%{!?_without_server:1} )
14f8ab
+%package ganesha
14f8ab
+Summary:          NFS-Ganesha configuration
14f8ab
+Group:            Applications/File
14f8ab
+
14f8ab
+Requires:         %{name}-server%{?_isa} = %{version}-%{release}
14f8ab
+Requires:         nfs-ganesha-gluster, pcs, dbus
14f8ab
+%if ( 0%{?rhel} && 0%{?rhel} == 6 )
14f8ab
+Requires:         cman, pacemaker, corosync
14f8ab
+%endif
14f8ab
+
14f8ab
+%description ganesha
14f8ab
+GlusterFS is a distributed file-system capable of scaling to several
14f8ab
+petabytes. It aggregates various storage bricks over Infiniband RDMA
14f8ab
+or TCP/IP interconnect into one large parallel network file
14f8ab
+system. GlusterFS is one of the most sophisticated file systems in
14f8ab
+terms of features and extensibility.  It borrows a powerful concept
14f8ab
+called Translators from GNU Hurd kernel. Much of the code in GlusterFS
14f8ab
+is in user space and easily manageable.
14f8ab
+
14f8ab
+This package provides the configuration and related files for using
14f8ab
+NFS-Ganesha as the NFS server using GlusterFS
14f8ab
+%endif
14f8ab
+
14f8ab
 %if ( 0%{!?_without_georeplication:1} )
14f8ab
 %package geo-replication
14f8ab
 Summary:          GlusterFS Geo-replication
14f8ab
@@ -1111,6 +1134,12 @@ exit 0
14f8ab
 %endif
14f8ab
 %endif
14f8ab
 
14f8ab
+%if ( 0%{?_without_server:1} )
14f8ab
+#exclude ganesha related files
14f8ab
+%exclude %{_sysconfdir}/ganesha/*
14f8ab
+%exclude %{_libexecdir}/ganesha/*
14f8ab
+%endif
14f8ab
+
14f8ab
 %files api
14f8ab
 %exclude %{_libdir}/*.so
14f8ab
 # libgfapi files
14f8ab
@@ -1273,6 +1302,12 @@ exit 0
14f8ab
 %exclude %{_datadir}/glusterfs/tests/vagrant
14f8ab
 %endif
14f8ab
 
14f8ab
+%if ( 0%{!?_without_server:1} )
14f8ab
+%files ganesha
14f8ab
+%{_sysconfdir}/ganesha/*
14f8ab
+%{_libexecdir}/ganesha/*
14f8ab
+%endif
14f8ab
+
14f8ab
 %if ( 0%{!?_without_ocf:1} )
14f8ab
 %files resource-agents
14f8ab
 # /usr/lib is the standard for OCF, also on x86_64
14f8ab
@@ -1396,6 +1431,7 @@ exit 0
14f8ab
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post
14f8ab
             %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post/S29CTDBsetup.sh
14f8ab
             %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post/S30samba-start.sh
14f8ab
+            %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post/S31ganesha-start.sh
14f8ab
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/pre
14f8ab
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop
14f8ab
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop/post
14f8ab
@@ -1868,6 +1904,9 @@ fi
14f8ab
 %endif
14f8ab
 
14f8ab
 %changelog
14f8ab
+* Fri Apr 5 2019 Jiffin Tony Thottan <jthottan@redhat.com>
14f8ab
+- Adding ganesha bits back in gluster repository
14f8ab
+
14f8ab
 * Wed Mar 6 2019 Kaleb S. KEITHLEY <kkeithle@redhat.com>
14f8ab
 - remove unneeded ldconfig in scriptlets
14f8ab
 -  reported by Igor Gnatenko in Fedora
14f8ab
@@ -1960,9 +1999,6 @@ fi
14f8ab
 * Thu Feb 16 2017 Niels de Vos <ndevos@redhat.com>
14f8ab
 - Obsolete and Provide python-gluster for upgrading from glusterfs < 3.10
14f8ab
 
14f8ab
-* Tue Feb 7 2017 Kaleb S. KEITHLEY <kkeithle@redhat.com>
14f8ab
-- remove ganesha (#1418417)
14f8ab
-
14f8ab
 * Wed Feb 1 2017 Poornima G <pgurusid@redhat.com>
14f8ab
 - Install /var/lib/glusterd/groups/metadata-cache by default
14f8ab
 
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab