]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Move NFS callout-related code to functions file
authorMartin Schwenke <martin@meltin.net>
Mon, 6 Jun 2016 03:56:55 +0000 (13:56 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 8 Jun 2016 08:33:19 +0000 (10:33 +0200)
A second NFS eventscript may be required, so make this code available
to it.

The initialisation code can't be evaluated in the functions file
because service_state_dir isn't yet setup, so put it in a function and
call it with other initialisation code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/events.d/60.nfs
ctdb/config/functions

index 57cfbffa2e95e051ed43ca6fb5cc1f563063ca6e..eb12ad6ac4c2f1a8ea721fb37b2dea6ef3082d6f 100755 (executable)
@@ -12,63 +12,6 @@ ctdb_setup_service_state_dir
 
 ######################################################################
 
-if [ -z "$CTDB_NFS_CALLOUT" ] ; then
-    CTDB_NFS_CALLOUT="${CTDB_BASE}/nfs-linux-kernel-callout"
-fi
-# Always export, for statd callout
-export CTDB_NFS_CALLOUT
-
-# If the callout wants to use this then it must create it
-export CTDB_NFS_CALLOUT_STATE_DIR="${service_state_dir}/callout-state"
-
-# Export, if set, for use by clustered NFS callouts
-if [ -n "$CTDB_NFS_STATE_FS_TYPE" ] ; then
-    export CTDB_NFS_STATE_FS_TYPE
-fi
-if [ -n "$CTDB_NFS_STATE_MNT" ] ; then
-    export CTDB_NFS_STATE_MNT
-fi
-
-nfs_callout_cache="${service_state_dir}/nfs_callout_cache"
-nfs_callout_cache_callout="${nfs_callout_cache}/CTDB_NFS_CALLOUT"
-nfs_callout_cache_ops="${nfs_callout_cache}/ops"
-
-nfs_callout_register ()
-{
-    mkdir -p "$nfs_callout_cache_ops"
-    rm -f "$nfs_callout_cache_ops"/*
-
-    echo "$CTDB_NFS_CALLOUT" >"$nfs_callout_cache_callout"
-
-    _t=$(eval "$CTDB_NFS_CALLOUT" "register")
-    if [ -n "$_t" ] ; then
-       echo "$_t" |
-           while IFS="" read _op ; do
-               touch "${nfs_callout_cache_ops}/${_op}"
-           done
-    else
-       touch "${nfs_callout_cache_ops}/ALL"
-    fi
-}
-
-nfs_callout ()
-{
-    # Re-run registration if $CTDB_NFS_CALLOUT has changed
-    _prev=""
-    if [ -r "$nfs_callout_cache_callout" ] ; then
-       read _prev <"$nfs_callout_cache_callout"
-    fi
-    if [ "$CTDB_NFS_CALLOUT" != "$_prev" ] ; then
-       nfs_callout_register
-    fi
-
-    # Run the operation if it is registered...
-    if [ -e "${nfs_callout_cache_ops}/${1}" ] || \
-          [ -e "${nfs_callout_cache_ops}/ALL" ]; then
-       eval "$CTDB_NFS_CALLOUT" "$@"
-    fi
-}
-
 service_reconfigure ()
 {
     # Restart lock manager, notify clients
@@ -294,6 +237,8 @@ nfs_update_lock_info ()
 
 ######################################################################
 
+nfs_callout_init
+
 ctdb_start_stop_service
 
 is_ctdb_managed_service || exit 0
index 33efa517e0bd975bf7c5e230f94094c602201377..b2a0735a2218d057ce6bb849d85b64554ae223c2 100755 (executable)
@@ -1164,6 +1164,69 @@ if ! type mktemp >/dev/null 2>&1 ; then
     }
 fi
 
+######################################################################
+# NFS callout handling
+
+nfs_callout_init ()
+{
+       if [ -z "$CTDB_NFS_CALLOUT" ] ; then
+               CTDB_NFS_CALLOUT="${CTDB_BASE}/nfs-linux-kernel-callout"
+       fi
+       # Always export, for statd callout
+       export CTDB_NFS_CALLOUT
+
+       # If the callout wants to use this then it must create it
+       export CTDB_NFS_CALLOUT_STATE_DIR="${service_state_dir}/callout-state"
+
+       # Export, if set, for use by clustered NFS callouts
+       if [ -n "$CTDB_NFS_STATE_FS_TYPE" ] ; then
+               export CTDB_NFS_STATE_FS_TYPE
+       fi
+       if [ -n "$CTDB_NFS_STATE_MNT" ] ; then
+               export CTDB_NFS_STATE_MNT
+       fi
+
+       nfs_callout_cache="${service_state_dir}/nfs_callout_cache"
+       nfs_callout_cache_callout="${nfs_callout_cache}/CTDB_NFS_CALLOUT"
+       nfs_callout_cache_ops="${nfs_callout_cache}/ops"
+}
+
+nfs_callout_register ()
+{
+    mkdir -p "$nfs_callout_cache_ops"
+    rm -f "$nfs_callout_cache_ops"/*
+
+    echo "$CTDB_NFS_CALLOUT" >"$nfs_callout_cache_callout"
+
+    _t=$(eval "$CTDB_NFS_CALLOUT" "register")
+    if [ -n "$_t" ] ; then
+       echo "$_t" |
+           while IFS="" read _op ; do
+               touch "${nfs_callout_cache_ops}/${_op}"
+           done
+    else
+       touch "${nfs_callout_cache_ops}/ALL"
+    fi
+}
+
+nfs_callout ()
+{
+    # Re-run registration if $CTDB_NFS_CALLOUT has changed
+    _prev=""
+    if [ -r "$nfs_callout_cache_callout" ] ; then
+       read _prev <"$nfs_callout_cache_callout"
+    fi
+    if [ "$CTDB_NFS_CALLOUT" != "$_prev" ] ; then
+       nfs_callout_register
+    fi
+
+    # Run the operation if it is registered...
+    if [ -e "${nfs_callout_cache_ops}/${1}" ] || \
+          [ -e "${nfs_callout_cache_ops}/ALL" ]; then
+       eval "$CTDB_NFS_CALLOUT" "$@"
+    fi
+}
+
 ########################################################
 # tickle handling
 ########################################################