diff options
| author | Krishnan Parthasarathi <kparthas@redhat.com> | 2012-06-13 11:27:54 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2012-06-13 23:58:40 +0530 | 
| commit | a83d2539ec7dbb6663444e88560e65db64bc8076 (patch) | |
| tree | eabdfa9358b4695255322d7d424251ed406b1753 | |
| parent | fb6f8c05d6fd804fe5d412149ebf7badf55a7b64 (diff) | |
hooks: Added fstab entry for samba share
- Add fstab entry for samba shares exported via hooks only on
  successfully mounting
- Remove fstab entry for samba export in samba-stop script
- Fixed an unintentional use of 'function-local' variable
  in shell script which relies on bash's variable scope internals.
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Signed-off-by: Vijay Bellur <vijay@gluster.com>
| -rw-r--r-- | extras/hook-scripts/start/post/S29CTDBsetup.sh | 4 | ||||
| -rw-r--r-- | extras/hook-scripts/start/post/S30samba-start.sh | 15 | ||||
| -rw-r--r-- | extras/hook-scripts/stop/pre/S30samba-stop.sh | 13 | 
3 files changed, 29 insertions, 3 deletions
diff --git a/extras/hook-scripts/start/post/S29CTDBsetup.sh b/extras/hook-scripts/start/post/S29CTDBsetup.sh index 7e44df21c58..2567cf8307e 100644 --- a/extras/hook-scripts/start/post/S29CTDBsetup.sh +++ b/extras/hook-scripts/start/post/S29CTDBsetup.sh @@ -69,9 +69,9 @@ then      #expects ctdb service to manage smb      service smb stop      add_glusterfs_ctdb_options -    add_fstab_entry $VOL $CTDB_MNT      mkdir -p $CTDB_MNT      sleep 5 -    mount -t glusterfs `hostname`:$VOL "$CTDB_MNT" +    mount -t glusterfs `hostname`:$VOL "$CTDB_MNT" && \ +        add_fstab_entry $VOL $CTDB_MNT      chkconfig ctdb on  fi diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh index 60c192aad08..b61c59cd3b5 100644 --- a/extras/hook-scripts/start/post/S30samba-start.sh +++ b/extras/hook-scripts/start/post/S30samba-start.sh @@ -41,9 +41,22 @@ function sighup_samba () {          fi  } +function add_fstab_entry () { +        volname=$1 +        mntpt=$2 +        mntent="`hostname`:/$volname $mntpt glusterfs defaults,transport=tcp 0 0" +        exists=`grep "$mntent" /etc/fstab` +        if [ "$exists" == "" ] +        then +            echo "$mntent" >> /etc/fstab +        fi +} +  parse_args $@  add_samba_export $VOL $MNT_PRE +mkdir -p $MNT_PRE/$VOL  sleep 5 -mount -t glusterfs `hostname`:$volname $mnt_pre/$volname +mount -t glusterfs `hostname`:$VOL $MNT_PRE/$VOL && \ +        add_fstab_entry $VOL $MNT_PRE/$VOL  sighup_samba diff --git a/extras/hook-scripts/stop/pre/S30samba-stop.sh b/extras/hook-scripts/stop/pre/S30samba-stop.sh index 783171a437e..83659e4ff4f 100644 --- a/extras/hook-scripts/stop/pre/S30samba-stop.sh +++ b/extras/hook-scripts/stop/pre/S30samba-stop.sh @@ -37,6 +37,18 @@ function umount_volume () {          umount -l $mnt_pre/$volname  } +function remove_fstab_entry () { +	volname=$1 +	mntpt=$2 +	mntent="`hostname`:/$volname $mntpt glusterfs defaults,transport=tcp 0 0" +	esc_mntent=$(echo -e "$mntent" | sed 's/\//\\\//g') +	exists=`grep "$mntent" /etc/fstab` +	if [ "$exists" != " " ] +	then +		sed -i /"$esc_mntent"/d /etc/fstab +	fi +} +  function sighup_samba () {          pid=`cat /var/run/smbd.pid`          if [ $pid != " " ] @@ -50,4 +62,5 @@ function sighup_samba () {  parse_args $@  del_samba_export $VOL  umount_volume $VOL $MNT_PRE +remove_fstab_entry $VOL $MNT_PRE/$VOL  sighup_samba  | 
