|
|
887953 |
From 644bcd954000b77fc8f49e3a7941de23ca869427 Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Anoop C S <anoopcs@redhat.com>
|
|
|
887953 |
Date: Wed, 21 Mar 2018 13:09:01 +0530
|
|
|
887953 |
Subject: [PATCH 481/493] extras/hooks: Do not blindly remove volume share from
|
|
|
887953 |
smb.conf
|
|
|
887953 |
|
|
|
887953 |
When Gluster volumes are shared via Samba, any extra smb.conf parameter
|
|
|
887953 |
setting done by administrator to those shares are lost during restart
|
|
|
887953 |
of the volume. Instead of removing the whole share completely from
|
|
|
887953 |
smb.conf(via hook scripts during volume stop) it is better to make it
|
|
|
887953 |
temporarily unavailable to end-users till the volume is started again.
|
|
|
887953 |
Therefore we make use of a smb.conf parameter named 'available'[1] to
|
|
|
887953 |
achieve the above intend.
|
|
|
887953 |
|
|
|
887953 |
[1] https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html
|
|
|
887953 |
|
|
|
887953 |
upstream ref: https://review.gluster.org/c/glusterfs/+/19750
|
|
|
887953 |
|
|
|
887953 |
Change-Id: I68a9055b50791f6ffd3b95a3c13d858a75fa6530
|
|
|
887953 |
BUG: 1164778
|
|
|
887953 |
Signed-off-by: Anoop C S <anoopcs@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/158495
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
extras/hook-scripts/set/post/S30samba-set.sh | 11 ++++++-----
|
|
|
887953 |
extras/hook-scripts/start/post/S30samba-start.sh | 4 +++-
|
|
|
887953 |
extras/hook-scripts/stop/pre/S30samba-stop.sh | 6 +++---
|
|
|
887953 |
3 files changed, 12 insertions(+), 9 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/extras/hook-scripts/set/post/S30samba-set.sh b/extras/hook-scripts/set/post/S30samba-set.sh
|
|
|
887953 |
index b93415b..c596db0 100755
|
|
|
887953 |
--- a/extras/hook-scripts/set/post/S30samba-set.sh
|
|
|
887953 |
+++ b/extras/hook-scripts/set/post/S30samba-set.sh
|
|
|
887953 |
@@ -103,9 +103,9 @@ function sighup_samba () {
|
|
|
887953 |
fi
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
-function del_samba_share () {
|
|
|
887953 |
+function deactivate_samba_share () {
|
|
|
887953 |
volname=$1
|
|
|
887953 |
- sed -i "/\[gluster-$volname\]/,/^$/d" ${CONFIGFILE}
|
|
|
887953 |
+ sed -i -e '/^\[gluster-'"$volname"'\]/{ :a' -e 'n; /available = no/H; /^$/!{$!ba;}; x; /./!{ s/^/available = no/; $!{G;x}; $H; }; s/.*//; x; };' ${CONFIGFILE}
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
function is_volume_started () {
|
|
|
887953 |
@@ -140,12 +140,13 @@ if [ "$USERCIFS_SET" = "YES" ] || [ "$USERSMB_SET" = "YES" ]; then
|
|
|
887953 |
find_config_info
|
|
|
887953 |
|
|
|
887953 |
if [ "$(get_smb "$VOL")" = "disable" ]; then
|
|
|
887953 |
- del_samba_share $VOL
|
|
|
887953 |
- sighup_samba
|
|
|
887953 |
+ deactivate_samba_share $VOL
|
|
|
887953 |
else
|
|
|
887953 |
if ! grep --quiet "\[gluster-$VOL\]" ${CONFIGFILE} ; then
|
|
|
887953 |
add_samba_share $VOL
|
|
|
887953 |
- sighup_samba
|
|
|
887953 |
+ else
|
|
|
887953 |
+ sed -i '/\[gluster-'"$VOL"'\]/,/^$/!b;/available = no/d' ${CONFIGFILE}
|
|
|
887953 |
fi
|
|
|
887953 |
fi
|
|
|
887953 |
+ sighup_samba
|
|
|
887953 |
fi
|
|
|
887953 |
diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh
|
|
|
887953 |
index 92ddaf4..5d586ee 100755
|
|
|
887953 |
--- a/extras/hook-scripts/start/post/S30samba-start.sh
|
|
|
887953 |
+++ b/extras/hook-scripts/start/post/S30samba-start.sh
|
|
|
887953 |
@@ -127,5 +127,7 @@ find_config_info
|
|
|
887953 |
|
|
|
887953 |
if ! grep --quiet "\[gluster-$VOL\]" ${CONFIGFILE} ; then
|
|
|
887953 |
add_samba_share $VOL
|
|
|
887953 |
- sighup_samba
|
|
|
887953 |
+else
|
|
|
887953 |
+ sed -i '/\[gluster-'"$VOL"'\]/,/^$/!b;/available = no/d' ${CONFIGFILE}
|
|
|
887953 |
fi
|
|
|
887953 |
+sighup_samba
|
|
|
887953 |
diff --git a/extras/hook-scripts/stop/pre/S30samba-stop.sh b/extras/hook-scripts/stop/pre/S30samba-stop.sh
|
|
|
887953 |
index 5e87845..ea79938 100755
|
|
|
887953 |
--- a/extras/hook-scripts/stop/pre/S30samba-stop.sh
|
|
|
887953 |
+++ b/extras/hook-scripts/stop/pre/S30samba-stop.sh
|
|
|
887953 |
@@ -56,9 +56,9 @@ function find_config_info () {
|
|
|
887953 |
PIDDIR=`smbd -b | grep PIDDIR | awk '{print $2}'`
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
-function del_samba_share () {
|
|
|
887953 |
+function deactivate_samba_share () {
|
|
|
887953 |
volname=$1
|
|
|
887953 |
- sed -i "/\[gluster-$volname\]/,/^$/d" ${CONFIGFILE}
|
|
|
887953 |
+ sed -i -e '/^\[gluster-'"$volname"'\]/{ :a' -e 'n; /available = no/H; /^$/!{$!ba;}; x; /./!{ s/^/available = no/; $!{G;x}; $H; }; s/.*//; x; };' ${CONFIGFILE}
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
function sighup_samba () {
|
|
|
887953 |
@@ -73,5 +73,5 @@ function sighup_samba () {
|
|
|
887953 |
|
|
|
887953 |
parse_args "$@"
|
|
|
887953 |
find_config_info
|
|
|
887953 |
-del_samba_share $VOL
|
|
|
887953 |
+deactivate_samba_share $VOL
|
|
|
887953 |
sighup_samba
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|