summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2012-06-12 14:45:27 +0530
committerVijay Bellur <vijay@gluster.com>2012-06-12 14:45:27 +0530
commit8e64475d72c6db64240df21a20a02fbae22609e2 (patch)
tree28a9cdc76ca18087d0d01d3cc553a0070eef7def /extras
parent7fb03a0ade154b0c21a71ce0e776a06e50510016 (diff)
hooks: Changes for ctdb start and stop
Diffstat (limited to 'extras')
-rw-r--r--extras/hook-scripts/start/post/S29CTDBsetup.sh42
-rw-r--r--extras/hook-scripts/stop/pre/S29CTDB-teardown.sh80
2 files changed, 105 insertions, 17 deletions
diff --git a/extras/hook-scripts/start/post/S29CTDBsetup.sh b/extras/hook-scripts/start/post/S29CTDBsetup.sh
index e256be1f3ea..7e44df21c58 100644
--- a/extras/hook-scripts/start/post/S29CTDBsetup.sh
+++ b/extras/hook-scripts/start/post/S29CTDBsetup.sh
@@ -1,5 +1,5 @@
#! /bin/bash
-#non-portable - RHS-2.0 only
+# RHS-2.0 only
# - The script mounts the 'meta-vol' on start 'event' on a known
# directory (eg. /gluster/lock)
# - Adds the necessary configuration changes for ctdb in smb.conf and
@@ -20,16 +20,6 @@ VOL=
# User needs to set META to the volume that serves CTDB lockfile.
META="all"
-function sighup_samba () {
- pid=`cat /var/run/smbd.pid`
- if [ $pid != " " ]
- then
- kill -HUP $pid;
- else
- /etc/init.d/smb start
- fi
-}
-
function parse_args () {
ARGS=$(getopt -l $OPTSPEC -name $PROGNAME $@)
eval set -- "$ARGS"
@@ -54,16 +44,34 @@ function parse_args () {
function add_glusterfs_ctdb_options () {
PAT="Share Definitions"
- GLUSTER_CTDB_CONFIG="# ctdb config for glusterfs\n\tclustering = yes\n\tidmap backend = tdb2\n\tprivate dir = "$CTDB_MNT"\n"
+ GLUSTER_CTDB_CONFIG="# ctdb config for glusterfs\n\tclustering = yes\n\tidmap backend = tdb2\n"
+ exists=`grep "clustering = yes" "$SMB_CONF"`
+ if [ "$exists" == "" ]
+ then
+ sed -i /"$PAT"/i\ "$GLUSTER_CTDB_CONFIG" "$SMB_CONF"
+ fi
+}
- sed -i /"$PAT"/i\ "$GLUSTER_CTDB_CONFIG" $SMB_CONF
+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 $@
if [ "$META" = "$VOL" ]
then
- add_glusterfs_ctdb_options
- sighup_samba
- mount -t glusterfs `hostname`:$VOL "$CTDB_MNT" &
+ #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"
+ chkconfig ctdb on
fi
-
diff --git a/extras/hook-scripts/stop/pre/S29CTDB-teardown.sh b/extras/hook-scripts/stop/pre/S29CTDB-teardown.sh
new file mode 100644
index 00000000000..30316f92f68
--- /dev/null
+++ b/extras/hook-scripts/stop/pre/S29CTDB-teardown.sh
@@ -0,0 +1,80 @@
+#! /bin/bash
+#non-portable - RHS-2.0 only
+SMB_CONF=/etc/samba/smb.conf
+
+CTDB_MNT=/gluster/lock
+PROGNAME="ctdb"
+OPTSPEC="volname:"
+VOL=
+# $META is the volume that will be used by CTDB as a shared filesystem.
+# It is not desirable to use this volume for storing 'data' as well.
+# META is set to 'all' (viz. a keyword and hence not a legal volume name)
+# to prevent the script from running for volumes it was not intended.
+# User needs to set META to the volume that serves CTDB lockfile.
+META="all"
+
+function sighup_samba () {
+ pid=`cat /var/run/smbd.pid`
+ if [ "$pid" != "" ]
+ then
+ kill -HUP $pid;
+ else
+ /etc/init.d/smb start
+ fi
+}
+
+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 remove_ctdb_options () {
+ IFS=$'\n'
+ GLUSTER_CTDB_CONFIG=$'# ctdb config for glusterfs\n\tclustering = yes\n\tidmap backend = tdb2\n'
+
+ for line in $GLUSTER_CTDB_CONFIG
+ do
+ sed -i /"$line"/d $SMB_CONF
+ done
+ unset IFS
+}
+
+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
+}
+
+parse_args $@
+if [ "$META" = "$VOL" ]
+then
+ umount "$CTDB_MNT"
+ chkconfig ctdb off
+ remove_fstab_entry $VOL $CTDB_MNT
+ remove_ctdb_options
+ sighup_samba
+fi