diff options
Diffstat (limited to 'extras/hook-scripts/S30samba-start.sh')
| -rwxr-xr-x | extras/hook-scripts/S30samba-start.sh | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/extras/hook-scripts/S30samba-start.sh b/extras/hook-scripts/S30samba-start.sh index 926fe6035..34fde0ef8 100755 --- a/extras/hook-scripts/S30samba-start.sh +++ b/extras/hook-scripts/S30samba-start.sh @@ -23,6 +23,9 @@ PROGNAME="Ssamba-start" OPTSPEC="volname:" VOL= +CONFIGFILE= +LOGFILEBASE= +PIDDIR= function parse_args () { ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@) @@ -43,21 +46,34 @@ function parse_args () { done } +function find_config_info () { + cmdout=`smbd -b | grep smb.conf` + if [ $? -ne 0 ];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}'` +} + function add_samba_share () { volname=$1 STRING="\n[gluster-$volname]\n" STRING+="comment = For samba share of volume $volname\n" STRING+="vfs objects = glusterfs\n" STRING+="glusterfs:volume = $volname\n" + STRING+="glusterfs:logfile = $LOGFILEBASE/glusterfs-$volname.%%M.log\n" + STRING+="glusterfs:loglevel = 7\n" STRING+="path = /\n" STRING+="read only = no\n" STRING+="guest ok = yes\n" - printf "$STRING" >> /etc/samba/smb.conf + printf "$STRING" >> ${CONFIGFILE} } function sighup_samba () { - pid=`cat /var/run/smbd.pid` - if [ "$pid" != "" ] + pid=`cat ${PIDDIR}/smbd.pid` + if [ "x$pid" != "x" ] then kill -HUP "$pid"; else @@ -85,5 +101,10 @@ if [ $(get_smb "$VOL") = "disable" ]; then exit 0 fi -add_samba_share $VOL -sighup_samba +#Find smb.conf, smbd pid directory and smbd logfile path +find_config_info + +if ! grep --quiet "\[gluster-$VOL\]" ${CONFIGFILE} ; then + add_samba_share $VOL + sighup_samba +fi |
