hookscripts: Changes in hook scripts to make it work on all Linux/GNU distribution
Removed the hard coded values for smb.conf, smb logfile location and smbd.pid. The current hook scripts also work for manully compiled (make, make install) instance of gluster and Samba. But we have to manually copy the hook scripts to respective locations. Change-Id: I14056830fcd2ecb48b3c4df89265f4408c8de3e3 Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com> Reviewed-on: http://review.gluster.org/5947 Reviewed-by: poornima g <pgurusid@redhat.com> Reviewed-by: susant palai <spalai@redhat.com> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Tested-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
This commit is contained in:
parent
8c1f5cffea
commit
31cacce770
@ -23,6 +23,9 @@
|
|||||||
PROGNAME="Ssamba-start"
|
PROGNAME="Ssamba-start"
|
||||||
OPTSPEC="volname:"
|
OPTSPEC="volname:"
|
||||||
VOL=
|
VOL=
|
||||||
|
CONFIGFILE=
|
||||||
|
LOGFILEBASE=
|
||||||
|
PIDDIR=
|
||||||
|
|
||||||
function parse_args () {
|
function parse_args () {
|
||||||
ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@)
|
ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@)
|
||||||
@ -43,22 +46,33 @@ function parse_args () {
|
|||||||
done
|
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 () {
|
function add_samba_share () {
|
||||||
volname=$1
|
volname=$1
|
||||||
STRING="\n[gluster-$volname]\n"
|
STRING="\n[gluster-$volname]\n"
|
||||||
STRING+="comment = For samba share of volume $volname\n"
|
STRING+="comment = For samba share of volume $volname\n"
|
||||||
STRING+="vfs objects = glusterfs\n"
|
STRING+="vfs objects = glusterfs\n"
|
||||||
STRING+="glusterfs:volume = $volname\n"
|
STRING+="glusterfs:volume = $volname\n"
|
||||||
STRING+="glusterfs:logfile = /var/log/samba/glusterfs-$volname.log\n"
|
STRING+="glusterfs:logfile = $LOGFILEBASE/glusterfs-$volname.log\n"
|
||||||
STRING+="glusterfs:loglevel = 7\n"
|
STRING+="glusterfs:loglevel = 7\n"
|
||||||
STRING+="path = /\n"
|
STRING+="path = /\n"
|
||||||
STRING+="read only = no\n"
|
STRING+="read only = no\n"
|
||||||
STRING+="guest ok = yes\n"
|
STRING+="guest ok = yes\n"
|
||||||
printf "$STRING" >> /etc/samba/smb.conf
|
printf "$STRING" >> ${CONFIGFILE}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sighup_samba () {
|
function sighup_samba () {
|
||||||
pid=`cat /var/run/smbd.pid`
|
pid=`cat ${PIDDIR}/smbd.pid`
|
||||||
if [ "$pid" != "" ]
|
if [ "$pid" != "" ]
|
||||||
then
|
then
|
||||||
kill -HUP "$pid";
|
kill -HUP "$pid";
|
||||||
@ -87,7 +101,10 @@ if [ $(get_smb "$VOL") = "disable" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep --quiet "gluster-$VOL" /etc/samba/smb.conf ; then
|
#Find smb.conf, smbd pid directory and smbd logfile path
|
||||||
|
find_config_info
|
||||||
|
|
||||||
|
if ! grep --quiet "gluster-$VOL" ${CONFIGFILE} ; then
|
||||||
add_samba_share $VOL
|
add_samba_share $VOL
|
||||||
sighup_samba
|
sighup_samba
|
||||||
fi
|
fi
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
PROGNAME="Ssamba-stop"
|
PROGNAME="Ssamba-stop"
|
||||||
OPTSPEC="volname:"
|
OPTSPEC="volname:"
|
||||||
VOL=
|
VOL=
|
||||||
|
CONFIGFILE=
|
||||||
|
PIDDIR=
|
||||||
|
|
||||||
function parse_args () {
|
function parse_args () {
|
||||||
ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@)
|
ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@)
|
||||||
@ -38,15 +40,25 @@ function parse_args () {
|
|||||||
done
|
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'}`
|
||||||
|
}
|
||||||
|
|
||||||
function del_samba_share () {
|
function del_samba_share () {
|
||||||
volname=$1
|
volname=$1
|
||||||
cp /etc/samba/smb.conf /tmp/smb.conf
|
cp ${CONFIGFILE} /tmp/smb.conf
|
||||||
sed -i "/gluster-$volname/,/^$/d" /tmp/smb.conf &&\
|
sed -i "/gluster-$volname/,/^$/d" /tmp/smb.conf &&\
|
||||||
cp /tmp/smb.conf /etc/samba/smb.conf
|
cp /tmp/smb.conf ${CONFIGFILE}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sighup_samba () {
|
function sighup_samba () {
|
||||||
pid=`cat /var/run/smbd.pid`
|
pid=`cat ${PIDDIR}/smbd.pid`
|
||||||
if [ $pid != "" ]
|
if [ $pid != "" ]
|
||||||
then
|
then
|
||||||
kill -HUP $pid;
|
kill -HUP $pid;
|
||||||
@ -56,5 +68,6 @@ function sighup_samba () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_args $@
|
parse_args $@
|
||||||
|
find_config_info
|
||||||
del_samba_share $VOL
|
del_samba_share $VOL
|
||||||
sighup_samba
|
sighup_samba
|
||||||
|
Loading…
Reference in New Issue
Block a user