From b28cab6483991e27078102075d29e2f15c967015 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Tue, 12 Jun 2012 14:53:04 +0530 Subject: hooks: Changes for samba start and stop --- extras/hook-scripts/start/post/S30samba-start.sh | 19 ++------ extras/hook-scripts/start/post/S30samba-stop.sh | 60 ------------------------ extras/hook-scripts/stop/pre/S30samba-stop.sh | 53 +++++++++++++++++++++ 3 files changed, 56 insertions(+), 76 deletions(-) delete mode 100644 extras/hook-scripts/start/post/S30samba-stop.sh create mode 100644 extras/hook-scripts/stop/pre/S30samba-stop.sh (limited to 'extras/hook-scripts') diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh index 5c7b6574e36..60c192aad08 100644 --- a/extras/hook-scripts/start/post/S30samba-start.sh +++ b/extras/hook-scripts/start/post/S30samba-start.sh @@ -1,11 +1,8 @@ #!/bin/bash -#Need to be copied to hooks//start/post PROGNAME="Ssamba-start" -OPTSPEC="volname:,mnt:" +OPTSPEC="volname:" VOL= -#FIXME: glusterd hook interface will eventually provide mntpt prefix as -# command line arg MNT_PRE="/mnt/samba" function parse_args () { @@ -18,10 +15,6 @@ function parse_args () { shift VOL=$1 ;; - --mnt) - shift - MNT_PRE=$1 - ;; *) shift break @@ -38,13 +31,6 @@ function add_samba_export () { printf "\n[gluster-$volname]\ncomment=For samba export of volume $volname\npath=$mnt_pre/$volname\nread only=no\nguest ok=yes\n" >> /etc/samba/smb.conf } -function mount_volume () { - volname=$1 - mnt_pre=$2 - #Mount shouldn't block on glusterd to fetch volfile, hence the 'bg' - mount -t glusterfs `hostname`:$volname $mnt_pre/$volname & -} - function sighup_samba () { pid=`cat /var/run/smbd.pid` if [ $pid != " " ] @@ -58,5 +44,6 @@ function sighup_samba () { parse_args $@ add_samba_export $VOL $MNT_PRE -mount_volume $VOL $MNT_PRE +sleep 5 +mount -t glusterfs `hostname`:$volname $mnt_pre/$volname sighup_samba diff --git a/extras/hook-scripts/start/post/S30samba-stop.sh b/extras/hook-scripts/start/post/S30samba-stop.sh deleted file mode 100644 index 0886f91bf9d..00000000000 --- a/extras/hook-scripts/start/post/S30samba-stop.sh +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/bash -#Need to be copied to hooks//stop/post - -PROGNAME="Ssamba-stop" -OPTSPEC="volname:,mnt:" -VOL= -#FIXME: gluster will eventually pass mnt prefix as command line argument -MNT_PRE="/mnt/samba" - -function parse_args () { - ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@) - eval set -- "$ARGS" - - while true; do - case $1 in - --volname) - shift - VOL=$1 - ;; - --mnt) - shift - MNT_PRE=$1 - echo $1 - ;; - *) - shift - break - ;; - esac - shift - done -} - -function del_samba_export () { - volname=$1 - cp /etc/samba/smb.conf /tmp/smb.conf - sed -i "/gluster-$volname/,/^$/d" /tmp/smb.conf &&\ - mv /tmp/smb.conf /etc/samba/smb.conf -} - -function umount_volume () { - volname=$1 - mnt_pre=$2 - umount -l $mnt_pre/$volname -} - -function sighup_samba () { - pid=`cat /var/run/smbd.pid` - if [ $pid != " " ] - then - kill -HUP $pid; - else - /etc/init.d/smb start - fi -} - -parse_args $@ -del_samba_export $VOL -umount_volume $VOL $MNT_PRE -sighup_samba diff --git a/extras/hook-scripts/stop/pre/S30samba-stop.sh b/extras/hook-scripts/stop/pre/S30samba-stop.sh new file mode 100644 index 00000000000..783171a437e --- /dev/null +++ b/extras/hook-scripts/stop/pre/S30samba-stop.sh @@ -0,0 +1,53 @@ +#! /bin/bash + +PROGNAME="Ssamba-stop" +OPTSPEC="volname:" +VOL= +MNT_PRE="/mnt/samba" + +function parse_args () { + ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@) + eval set -- "$ARGS" + + while true; do + case $1 in + --volname) + shift + VOL=$1 + ;; + *) + shift + break + ;; + esac + shift + done +} + +function del_samba_export () { + volname=$1 + cp /etc/samba/smb.conf /tmp/smb.conf + sed -i "/gluster-$volname/,/^$/d" /tmp/smb.conf &&\ + mv /tmp/smb.conf /etc/samba/smb.conf +} + +function umount_volume () { + volname=$1 + mnt_pre=$2 + umount -l $mnt_pre/$volname +} + +function sighup_samba () { + pid=`cat /var/run/smbd.pid` + if [ $pid != " " ] + then + kill -HUP $pid; + else + /etc/init.d/smb start + fi +} + +parse_args $@ +del_samba_export $VOL +umount_volume $VOL $MNT_PRE +sighup_samba -- cgit