|
|
887953 |
From 121180edc218432a782a153e94b9f884d4c56a7c Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Anoop C S <anoopcs@redhat.com>
|
|
|
887953 |
Date: Sun, 9 Sep 2018 11:39:47 +0530
|
|
|
887953 |
Subject: [PATCH 482/493] extras/hooks: General improvements to
|
|
|
887953 |
S30samba-start.sh
|
|
|
887953 |
|
|
|
887953 |
Based on https://review.gluster.org/c/glusterfs/+/19204 from
|
|
|
887953 |
Milan Zink <mzink@redhat.com>
|
|
|
887953 |
|
|
|
887953 |
upstream ref: https://review.gluster.org/c/glusterfs/+/21124
|
|
|
887953 |
|
|
|
887953 |
Change-Id: I61f62407a62475a74a6cc046c24748a31c66e6cd
|
|
|
887953 |
BUG: 1541568
|
|
|
887953 |
Signed-off-by: Anoop C S <anoopcs@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/158496
|
|
|
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/start/post/S30samba-start.sh | 26 ++++++++++++------------
|
|
|
887953 |
1 file changed, 13 insertions(+), 13 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh
|
|
|
887953 |
index 5d586ee..dfd9c1b 100755
|
|
|
887953 |
--- a/extras/hook-scripts/start/post/S30samba-start.sh
|
|
|
887953 |
+++ b/extras/hook-scripts/start/post/S30samba-start.sh
|
|
|
887953 |
@@ -68,14 +68,14 @@ function parse_args () {
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
function find_config_info () {
|
|
|
887953 |
- cmdout=`smbd -b | grep smb.conf`
|
|
|
887953 |
- if [ $? -ne 0 ];then
|
|
|
887953 |
+ cmdout=$(smbd -b 2> /dev/null)
|
|
|
887953 |
+ CONFIGFILE=$(echo "$cmdout" | grep CONFIGFILE | awk '{print $2}')
|
|
|
887953 |
+ if [ -z "$CONFIGFILE" ]; then
|
|
|
887953 |
echo "Samba is not installed"
|
|
|
887953 |
exit 1
|
|
|
887953 |
fi
|
|
|
887953 |
- CONFIGFILE=`echo $cmdout | awk '{print $2}'`
|
|
|
887953 |
- PIDDIR=`smbd -b | grep PIDDIR | awk '{print $2}'`
|
|
|
887953 |
- LOGFILEBASE=`smbd -b | grep 'LOGFILEBASE' | awk '{print $2}'`
|
|
|
887953 |
+ PIDDIR=$(echo "$cmdout" | grep PIDDIR | awk '{print $2}')
|
|
|
887953 |
+ LOGFILEBASE=$(echo "$cmdout" | grep 'LOGFILEBASE' | awk '{print $2}')
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
function add_samba_share () {
|
|
|
887953 |
@@ -89,11 +89,11 @@ function add_samba_share () {
|
|
|
887953 |
STRING+="path = /\n"
|
|
|
887953 |
STRING+="read only = no\n"
|
|
|
887953 |
STRING+="guest ok = yes\n"
|
|
|
887953 |
- printf "$STRING" >> ${CONFIGFILE}
|
|
|
887953 |
+ printf "$STRING" >> "${CONFIGFILE}"
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
function sighup_samba () {
|
|
|
887953 |
- pid=`cat ${PIDDIR}/smbd.pid`
|
|
|
887953 |
+ pid=$(cat "${PIDDIR}/smbd.pid" 2> /dev/null)
|
|
|
887953 |
if [ "x$pid" != "x" ]
|
|
|
887953 |
then
|
|
|
887953 |
kill -HUP "$pid";
|
|
|
887953 |
@@ -106,12 +106,12 @@ function get_smb () {
|
|
|
887953 |
volname=$1
|
|
|
887953 |
uservalue=
|
|
|
887953 |
|
|
|
887953 |
- usercifsvalue=$(grep user.cifs $GLUSTERD_WORKDIR/vols/"$volname"/info |\
|
|
|
887953 |
+ usercifsvalue=$(grep user.cifs "$GLUSTERD_WORKDIR"/vols/"$volname"/info |\
|
|
|
887953 |
cut -d"=" -f2)
|
|
|
887953 |
- usersmbvalue=$(grep user.smb $GLUSTERD_WORKDIR/vols/"$volname"/info |\
|
|
|
887953 |
+ usersmbvalue=$(grep user.smb "$GLUSTERD_WORKDIR"/vols/"$volname"/info |\
|
|
|
887953 |
cut -d"=" -f2)
|
|
|
887953 |
|
|
|
887953 |
- if [ $usercifsvalue = "disable" ] || [ $usersmbvalue = "disable" ]; then
|
|
|
887953 |
+ if [ "$usercifsvalue" = "disable" ] || [ "$usersmbvalue" = "disable" ]; then
|
|
|
887953 |
uservalue="disable"
|
|
|
887953 |
fi
|
|
|
887953 |
echo "$uservalue"
|
|
|
887953 |
@@ -125,9 +125,9 @@ fi
|
|
|
887953 |
#Find smb.conf, smbd pid directory and smbd logfile path
|
|
|
887953 |
find_config_info
|
|
|
887953 |
|
|
|
887953 |
-if ! grep --quiet "\[gluster-$VOL\]" ${CONFIGFILE} ; then
|
|
|
887953 |
- add_samba_share $VOL
|
|
|
887953 |
+if ! grep --quiet "\[gluster-$VOL\]" "${CONFIGFILE}" ; then
|
|
|
887953 |
+ add_samba_share "$VOL"
|
|
|
887953 |
else
|
|
|
887953 |
- sed -i '/\[gluster-'"$VOL"'\]/,/^$/!b;/available = no/d' ${CONFIGFILE}
|
|
|
887953 |
+ sed -i '/\[gluster-'"$VOL"'\]/,/^$/!b;/available = no/d' "${CONFIGFILE}"
|
|
|
887953 |
fi
|
|
|
887953 |
sighup_samba
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|