diff options
Diffstat (limited to 'extras/hook-scripts/stop/pre/S30samba-stop.sh')
-rw-r--r-- | extras/hook-scripts/stop/pre/S30samba-stop.sh | 53 |
1 files changed, 53 insertions, 0 deletions
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 |