diff options
author | Anoop C S <anoopcs@redhat.com> | 2018-09-09 11:39:47 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-09-14 07:09:38 +0000 |
commit | 76cb1e761d18482512d907679d279d7f61902dde (patch) | |
tree | 822925c35b228c90b522458e4692ef22afc3d618 /extras/hook-scripts/start | |
parent | 9f49f0b5901e29b8f0761c0e2631cd1c1d969a51 (diff) |
extras/hooks: General improvements to S30samba-start.sh
Based on https://review.gluster.org/c/glusterfs/+/19204 from
Milan Zink <mzink@redhat.com>
Change-Id: I61f62407a62475a74a6cc046c24748a31c66e6cd
Updates: bz#1193929
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Diffstat (limited to 'extras/hook-scripts/start')
-rwxr-xr-x | extras/hook-scripts/start/post/S30samba-start.sh | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh index 5d586ee9fae..dfd9c1b46ab 100755 --- a/extras/hook-scripts/start/post/S30samba-start.sh +++ b/extras/hook-scripts/start/post/S30samba-start.sh @@ -68,14 +68,14 @@ function parse_args () { } function find_config_info () { - cmdout=`smbd -b | grep smb.conf` - if [ $? -ne 0 ];then + cmdout=$(smbd -b 2> /dev/null) + CONFIGFILE=$(echo "$cmdout" | grep CONFIGFILE | awk '{print $2}') + if [ -z "$CONFIGFILE" ]; then echo "Samba is not installed" exit 1 fi - CONFIGFILE=`echo $cmdout | awk '{print $2}'` - PIDDIR=`smbd -b | grep PIDDIR | awk '{print $2}'` - LOGFILEBASE=`smbd -b | grep 'LOGFILEBASE' | awk '{print $2}'` + PIDDIR=$(echo "$cmdout" | grep PIDDIR | awk '{print $2}') + LOGFILEBASE=$(echo "$cmdout" | grep 'LOGFILEBASE' | awk '{print $2}') } function add_samba_share () { @@ -89,11 +89,11 @@ function add_samba_share () { STRING+="path = /\n" STRING+="read only = no\n" STRING+="guest ok = yes\n" - printf "$STRING" >> ${CONFIGFILE} + printf "$STRING" >> "${CONFIGFILE}" } function sighup_samba () { - pid=`cat ${PIDDIR}/smbd.pid` + pid=$(cat "${PIDDIR}/smbd.pid" 2> /dev/null) if [ "x$pid" != "x" ] then kill -HUP "$pid"; @@ -106,12 +106,12 @@ function get_smb () { volname=$1 uservalue= - usercifsvalue=$(grep user.cifs $GLUSTERD_WORKDIR/vols/"$volname"/info |\ + usercifsvalue=$(grep user.cifs "$GLUSTERD_WORKDIR"/vols/"$volname"/info |\ cut -d"=" -f2) - usersmbvalue=$(grep user.smb $GLUSTERD_WORKDIR/vols/"$volname"/info |\ + usersmbvalue=$(grep user.smb "$GLUSTERD_WORKDIR"/vols/"$volname"/info |\ cut -d"=" -f2) - if [ $usercifsvalue = "disable" ] || [ $usersmbvalue = "disable" ]; then + if [ "$usercifsvalue" = "disable" ] || [ "$usersmbvalue" = "disable" ]; then uservalue="disable" fi echo "$uservalue" @@ -125,9 +125,9 @@ fi #Find smb.conf, smbd pid directory and smbd logfile path find_config_info -if ! grep --quiet "\[gluster-$VOL\]" ${CONFIGFILE} ; then - add_samba_share $VOL +if ! grep --quiet "\[gluster-$VOL\]" "${CONFIGFILE}" ; then + add_samba_share "$VOL" else - sed -i '/\[gluster-'"$VOL"'\]/,/^$/!b;/available = no/d' ${CONFIGFILE} + sed -i '/\[gluster-'"$VOL"'\]/,/^$/!b;/available = no/d' "${CONFIGFILE}" fi sighup_samba |