diff options
Diffstat (limited to 'extras/hook-scripts')
| -rw-r--r-- | extras/hook-scripts/Makefile.am | 2 | ||||
| -rwxr-xr-x | extras/hook-scripts/S30samba-set.sh | 14 | ||||
| -rwxr-xr-x | extras/hook-scripts/S30samba-start.sh | 31 | ||||
| -rwxr-xr-x | extras/hook-scripts/S30samba-stop.sh | 21 | ||||
| -rwxr-xr-x | extras/hook-scripts/S56glusterd-geo-rep-create-post.sh | 42 |
5 files changed, 93 insertions, 17 deletions
diff --git a/extras/hook-scripts/Makefile.am b/extras/hook-scripts/Makefile.am index 924c07c9e..f6bded20c 100644 --- a/extras/hook-scripts/Makefile.am +++ b/extras/hook-scripts/Makefile.am @@ -1 +1 @@ -EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh S30samba-stop.sh S30samba-set.sh +EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh S30samba-stop.sh S30samba-set.sh S56glusterd-geo-rep-create-post.sh diff --git a/extras/hook-scripts/S30samba-set.sh b/extras/hook-scripts/S30samba-set.sh index 33ffca3d7..6b11f5a4f 100755 --- a/extras/hook-scripts/S30samba-set.sh +++ b/extras/hook-scripts/S30samba-set.sh @@ -63,6 +63,8 @@ function add_samba_share () { STRING+="comment = For samba share of volume $volname\n" STRING+="vfs objects = glusterfs\n" STRING+="glusterfs:volume = $volname\n" + STRING+="glusterfs:logfile = /var/log/samba/glusterfs-$volname.%%M.log\n" + STRING+="glusterfs:loglevel = 7\n" STRING+="path = /\n" STRING+="read only = no\n" STRING+="guest ok = yes\n" @@ -71,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 @@ -81,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 () { @@ -98,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 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 diff --git a/extras/hook-scripts/S30samba-stop.sh b/extras/hook-scripts/S30samba-stop.sh index def87e00e..8950eea43 100755 --- a/extras/hook-scripts/S30samba-stop.sh +++ b/extras/hook-scripts/S30samba-stop.sh @@ -18,6 +18,8 @@ PROGNAME="Ssamba-stop" OPTSPEC="volname:" VOL= +CONFIGFILE= +PIDDIR= function parse_args () { ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@) @@ -38,16 +40,24 @@ 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'}` +} + 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" ${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 @@ -56,5 +66,6 @@ function sighup_samba () { } parse_args $@ +find_config_info del_samba_share $VOL sighup_samba diff --git a/extras/hook-scripts/S56glusterd-geo-rep-create-post.sh b/extras/hook-scripts/S56glusterd-geo-rep-create-post.sh new file mode 100755 index 000000000..1369c22fc --- /dev/null +++ b/extras/hook-scripts/S56glusterd-geo-rep-create-post.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +key_val_pair1=`echo $2 | cut -d ' ' -f 1` +key_val_pair2=`echo $2 | cut -d ' ' -f 2` +key_val_pair3=`echo $2 | cut -d ' ' -f 3` + +key=`echo $key_val_pair1 | cut -d '=' -f 1` +val=`echo $key_val_pair1 | cut -d '=' -f 2` +if [ "$key" != "is_push_pem" ]; then + exit; +fi +if [ "$val" != '1' ]; then + exit; +fi + +key=`echo $key_val_pair2 | cut -d '=' -f 1` +val=`echo $key_val_pair2 | cut -d '=' -f 2` +if [ "$key" != "pub_file" ]; then + exit; +fi +if [ "$val" == "" ]; then + exit; +fi +pub_file=`echo $val` +pub_file_tmp=`echo $val`_tmp + +key=`echo $key_val_pair3 | cut -d '=' -f 1` +val=`echo $key_val_pair3 | cut -d '=' -f 2` +if [ "$key" != "slave_ip" ]; then + exit; +fi +if [ "$val" == "" ]; then + exit; +fi +slave_ip=`echo $val` + +if [ -f $pub_file ]; then + scp $pub_file $slave_ip:$pub_file_tmp + ssh $slave_ip "mv $pub_file_tmp $pub_file" + ssh $slave_ip "gluster system:: copy file /geo-replication/common_secret.pem.pub > /dev/null" + ssh $slave_ip "gluster system:: execute add_secret_pub > /dev/null" +fi |
