summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorRaghavendra Talur <rtalur@redhat.com>2013-10-07 13:08:49 +0530
committerAnand Avati <avati@redhat.com>2013-10-08 09:22:00 -0700
commit11bb1fc5849a557d1a26e59bd651fbd0d07a1b8d (patch)
tree08cd90bc0189b9b09d8f5eae89947805c7001d32 /extras
parent1f6b0f5cfc5abebe3a8facfb8b72e5554c1314d2 (diff)
extras/hookscripts: Fix the multiple entries in smb.conf problem.
Problem: 1. Force starts and user.smb sets were adding multiple entries to the smb.conf file for the same volume. Make a check for the entry and search with exact name. 2. Again, while deleting the share name from smb.conf search with exact name so that volumes with names which are substrings of ones to be deleted don't get deleted. 3. We don't need to use a tmp file while using sed -i, fixed that. Change-Id: Ie0f7c9d4790ef9a177a043378a761c9ffe1628e5 BUG: 994727 Signed-off-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-on: http://review.gluster.org/6043 Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Lalatendu Mohanty <lmohanty@redhat.com> Tested-by: Lalatendu Mohanty <lmohanty@redhat.com>
Diffstat (limited to 'extras')
-rwxr-xr-xextras/hook-scripts/S30samba-set.sh12
-rwxr-xr-xextras/hook-scripts/S30samba-start.sh4
-rwxr-xr-xextras/hook-scripts/S30samba-stop.sh6
3 files changed, 10 insertions, 12 deletions
diff --git a/extras/hook-scripts/S30samba-set.sh b/extras/hook-scripts/S30samba-set.sh
index 87cd31c5a2a..5047660fe7d 100755
--- a/extras/hook-scripts/S30samba-set.sh
+++ b/extras/hook-scripts/S30samba-set.sh
@@ -73,7 +73,7 @@ function add_samba_share () {
function sighup_samba () {
pid=`cat /var/run/smbd.pid`
- if [ "$pid" != "" ]
+ if [ "x$pid" != "x" ]
then
kill -HUP "$pid";
else
@@ -83,9 +83,7 @@ function sighup_samba () {
function del_samba_share () {
volname=$1
- cp /etc/samba/smb.conf /tmp/smb.conf
- sed -i "/gluster-$volname/,/^$/d" /tmp/smb.conf &&\
- cp /tmp/smb.conf /etc/samba/smb.conf
+ sed -i "/\[gluster-$volname\]/,/^$/d" /etc/samba/smb.conf
}
function is_volume_started () {
@@ -100,8 +98,10 @@ if [ "0" = $(is_volume_started "$VOL") ]; then
fi
if [ "$enable_smb" = "enable" ]; then
- add_samba_share $VOL
- sighup_samba
+ if ! grep --quiet "\[gluster-$VOL\]" /etc/samba/smb.conf ; then
+ add_samba_share $VOL
+ sighup_samba
+ fi
elif [ "$enable_smb" = "disable" ]; then
del_samba_share $VOL
diff --git a/extras/hook-scripts/S30samba-start.sh b/extras/hook-scripts/S30samba-start.sh
index 191b1dbb438..9f1b20a25b0 100755
--- a/extras/hook-scripts/S30samba-start.sh
+++ b/extras/hook-scripts/S30samba-start.sh
@@ -73,7 +73,7 @@ function add_samba_share () {
function sighup_samba () {
pid=`cat ${PIDDIR}/smbd.pid`
- if [ "$pid" != "" ]
+ if [ "x$pid" != "x" ]
then
kill -HUP "$pid";
else
@@ -104,7 +104,7 @@ fi
#Find smb.conf, smbd pid directory and smbd logfile path
find_config_info
-if ! grep --quiet "gluster-$VOL" ${CONFIGFILE} ; then
+if ! grep --quiet "\[gluster-$VOL\]" ${CONFIGFILE} ; then
add_samba_share $VOL
sighup_samba
fi
diff --git a/extras/hook-scripts/S30samba-stop.sh b/extras/hook-scripts/S30samba-stop.sh
index f7150c10e50..8950eea436e 100755
--- a/extras/hook-scripts/S30samba-stop.sh
+++ b/extras/hook-scripts/S30samba-stop.sh
@@ -52,14 +52,12 @@ function find_config_info () {
function del_samba_share () {
volname=$1
- cp ${CONFIGFILE} /tmp/smb.conf
- sed -i "/gluster-$volname/,/^$/d" /tmp/smb.conf &&\
- cp /tmp/smb.conf ${CONFIGFILE}
+ sed -i "/\[gluster-$volname\]/,/^$/d" ${CONFIGFILE}
}
function sighup_samba () {
pid=`cat ${PIDDIR}/smbd.pid`
- if [ $pid != "" ]
+ if [ "x$pid" != "x" ]
then
kill -HUP $pid;
else