summaryrefslogtreecommitdiffstats
path: root/extras/ganesha/scripts/create-export-ganesha.sh
diff options
context:
space:
mode:
authorJiffin Tony Thottan <jthottan@redhat.com>2017-10-16 14:18:31 +0530
committerAmar Tumballi <amarts@gmail.com>2019-08-24 02:08:57 +0000
commit3fe34c921146a8d11875dc3d904e3a5994eb1cb6 (patch)
treecbf3602eff2c1d180ecce02eda30ed19acf71928 /extras/ganesha/scripts/create-export-ganesha.sh
parent032862fa3944fc7152140aaa13cdc474ae594a51 (diff)
Revert "packaging: (ganesha) remove glusterfs-ganesha subpackage and related files"
Until 3.12, glusterd had an option to setup HA cluster for nfs-ganesha using pacemaker and corosync. But later infavour of "Storhaug" Project, this functionality was removed from the codebase. Since there is not much development happening towards storhaug, it better to keep back old working HA solution for nfs-ganesha with bit improvements. Planned improvements : * add an option in nfs-ganesha enable to set ganesha without HA. * Handle usage of export id's properly in the scripts. Change-Id: I1d60c8970bfc20035cf674d7b2705dfd4819647e updates: #663 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Diffstat (limited to 'extras/ganesha/scripts/create-export-ganesha.sh')
-rwxr-xr-xextras/ganesha/scripts/create-export-ganesha.sh91
1 files changed, 91 insertions, 0 deletions
diff --git a/extras/ganesha/scripts/create-export-ganesha.sh b/extras/ganesha/scripts/create-export-ganesha.sh
new file mode 100755
index 00000000000..1ffba427457
--- /dev/null
+++ b/extras/ganesha/scripts/create-export-ganesha.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+#This script is called by glusterd when the user
+#tries to export a volume via NFS-Ganesha.
+#An export file specific to a volume
+#is created in GANESHA_DIR/exports.
+
+# 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%/}
+OPTION=$2
+VOL=$3
+CONF=$GANESHA_DIR"/ganesha.conf"
+declare -i EXPORT_ID
+
+function check_cmd_status()
+{
+ if [ "$1" != "0" ]
+ then
+ rm -rf $GANESHA_DIR/exports/export.$VOL.conf
+ sed -i /$VOL.conf/d $CONF
+ exit 1
+ fi
+}
+
+
+if [ ! -d "$GANESHA_DIR/exports" ];
+ then
+ mkdir $GANESHA_DIR/exports
+ check_cmd_status `echo $?`
+fi
+
+function write_conf()
+{
+echo -e "# WARNING : Using Gluster CLI will overwrite manual
+# changes made to this file. To avoid it, edit the
+# file and run ganesha-ha.sh --refresh-config."
+
+echo "EXPORT{"
+echo " Export_Id = 2;"
+echo " Path = \"/$VOL\";"
+echo " FSAL {"
+echo " name = "GLUSTER";"
+echo " hostname=\"localhost\";"
+echo " volume=\"$VOL\";"
+echo " }"
+echo " Access_type = RW;"
+echo " Disable_ACL = true;"
+echo ' Squash="No_root_squash";'
+echo " Pseudo=\"/$VOL\";"
+echo ' Protocols = "3", "4" ;'
+echo ' Transports = "UDP","TCP";'
+echo ' SecType = "sys";'
+echo " }"
+}
+if [ "$OPTION" = "on" ];
+then
+ if ! (cat $CONF | grep $VOL.conf\"$ )
+ then
+ write_conf $@ > $GANESHA_DIR/exports/export.$VOL.conf
+ echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF
+ count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l`
+ if [ "$count" = "1" ] ; then
+ EXPORT_ID=2
+ else
+ EXPORT_ID=`cat $GANESHA_DIR/.export_added`
+ check_cmd_status `echo $?`
+ EXPORT_ID=EXPORT_ID+1
+ sed -i s/Export_Id.*/"Export_Id= $EXPORT_ID ;"/ \
+ $GANESHA_DIR/exports/export.$VOL.conf
+ check_cmd_status `echo $?`
+ fi
+ echo $EXPORT_ID > $GANESHA_DIR/.export_added
+ fi
+else
+ rm -rf $GANESHA_DIR/exports/export.$VOL.conf
+ sed -i /$VOL.conf/d $CONF
+fi