summaryrefslogtreecommitdiffstats
path: root/extras/ganesha/scripts/copy-export-ganesha.sh
diff options
context:
space:
mode:
authorJiffin Tony Thottan <jthottan@redhat.com>2016-04-18 21:34:32 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-05-06 05:59:44 -0700
commit058a5a7bf5fa099fe2d6de86ac35fa5594b1ebd8 (patch)
treeef846c8eb6a52de0c5c8542f374d6c6b182c6d20 /extras/ganesha/scripts/copy-export-ganesha.sh
parentfd8921b9eb03af69815bb2d7cff07b63048c2d5a (diff)
glusterd-ganesha : copy ganesha export configuration files during reboot
glusterd creates export conf file for ganesha using hook script during volume start and ganesha_manage_export() for volume set command. But this routine is not added in glusterd restart scenario. Consider the following case, in a three node cluster a volume got exported via ganesha while one of the node is offline(glusterd is not running). When the node comes back online, that volume is not exported on that node due to the above mentioned issue. Also I have removed unused variables from glusterd_handle_ganesha_op() For this patch to work pcs cluster should running on that be node. Upstream reference >Change-Id: I5b2312c2f3cef962b1f795b9f16c8f0a27f08ee5 >BUG: 1330097 >Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>i >Reviewed-on: http://review.gluster.org/14063 >Smoke: Gluster Build System <jenkins@build.gluster.com> >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> >CentOS-regression: Gluster Build System <jenkins@build.gluster.com> >Reviewed-by: soumya k <skoduri@redhat.com> >Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Change-Id: I5b2312c2f3cef962b1f795b9f16c8f0a27f08ee5 BUG: 1333661 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/14233 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'extras/ganesha/scripts/copy-export-ganesha.sh')
-rwxr-xr-xextras/ganesha/scripts/copy-export-ganesha.sh97
1 files changed, 97 insertions, 0 deletions
diff --git a/extras/ganesha/scripts/copy-export-ganesha.sh b/extras/ganesha/scripts/copy-export-ganesha.sh
new file mode 100755
index 00000000000..e8cdc98056c
--- /dev/null
+++ b/extras/ganesha/scripts/copy-export-ganesha.sh
@@ -0,0 +1,97 @@
+#/bin/bash
+
+#This script is called by glusterd when in case of
+#reboot.An export file specific to a volume
+#is copied in GANESHA_DIR/exports from online node.
+
+# Try loading the config from any of the distro
+# specific configuration locations
+if [ -f /etc/sysconfig/ganesha ]
+ then
+ . /etc/sysconfig/ganesha
+fi
+if [ -f /etc/conf.d/ganesha ]
+ then
+ . /etc/conf.d/ganesha
+fi
+if [ -f /etc/default/ganesha ]
+ then
+ . /etc/default/ganesha
+fi
+
+GANESHA_DIR=${1%/}
+VOL=$2
+CONF=
+host=$(hostname -s)
+SECRET_PEM="/var/lib/glusterd/nfs/secret.pem"
+
+function check_cmd_status()
+{
+ if [ "$1" != "0" ]
+ then
+ rm -rf $GANESHA_DIR/exports/export.$VOL.conf
+ exit 1
+ fi
+}
+
+
+if [ ! -d "$GANESHA_DIR/exports" ];
+ then
+ mkdir $GANESHA_DIR/exports
+ check_cmd_status `echo $?`
+fi
+
+function find_rhel7_conf
+{
+ while [[ $# > 0 ]]
+ do
+ key="$1"
+ case $key in
+ -f)
+ CONFFILE="$2"
+ ;;
+ *)
+ ;;
+ esac
+ shift
+ done
+}
+
+if [ -z $CONFFILE ]; then
+ find_rhel7_conf $OPTIONS
+
+fi
+CONF=${CONFFILE:-/etc/ganesha/ganesha.conf}
+
+#remove the old export entry from NFS-Ganesha
+#if already exported
+dbus-send --type=method_call --print-reply --system \
+ --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
+ org.ganesha.nfsd.exportmgr.ShowExports \
+ | grep -w -q "/$VOL"
+if [ $? -eq 0 ]; then
+ removed_id=`cat $GANESHA_DIR/exports/export.$VOL.conf |\
+ grep Export_Id | awk -F"[=,;]" '{print$2}' | tr -d '[[:space:]]'`
+
+ dbus-send --print-reply --system --dest=org.ganesha.nfsd \
+ /org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.RemoveExport \
+ uint16:$removed_id 2>&1
+fi
+
+ha_servers=$(pcs status | grep "Online:" | grep -o '\[.*\]' | sed -e 's/\[//' | sed -e 's/\]//')
+IFS=$' '
+for server in ${ha_servers} ; do
+ current_host=`echo $server | cut -d "." -f 1`
+ if [ $host != $current_host ]
+ then
+ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
+ ${SECRET_PEM} $server:$GANESHA_DIR/exports/export.$VOL.conf \
+ $GANESHA_DIR/exports/export.$VOL.conf
+ break
+ fi
+done
+
+if ! (cat $CONF | grep $VOL.conf\"$ )
+then
+echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF
+fi