From 95ed6f8725eae8a40db86d2b89a7f9bccebe22c2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Jun 2007 13:50:18 +1000 Subject: [PATCH] added CTDB_WAIT_DIRECTORIES support (This used to be ctdb commit fa888e8b1715d7460f5718d3e1fe17e4caaa15c3) --- ctdb/packaging/RHEL/setup/ctdb.sysconfig | 5 +++++ ctdb/tools/events | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ctdb/packaging/RHEL/setup/ctdb.sysconfig b/ctdb/packaging/RHEL/setup/ctdb.sysconfig index f6d13142d3b..fdcbfbe8e0a 100644 --- a/ctdb/packaging/RHEL/setup/ctdb.sysconfig +++ b/ctdb/packaging/RHEL/setup/ctdb.sysconfig @@ -47,6 +47,11 @@ # the default is not to wait for any local services # CTDB_WAIT_TCP_PORTS="445 139" +# use this to specify any local directories to wait on before starting +# ctdb. You should list any critical Samba or NFS shared directories +# the default is not to wait for any local directories +# CTDB_WAIT_DIRECTORIES="/some/directory" + # the shared directory where you want to put statd information on # which clients to notify on a NFS restart # there is no default diff --git a/ctdb/tools/events b/ctdb/tools/events index 20c7653bb2a..30944bd188a 100755 --- a/ctdb/tools/events +++ b/ctdb/tools/events @@ -8,10 +8,10 @@ shift case $cmd in startup) - # wait for local services to come up + # wait for local services to come up. [ -z "$CTDB_WAIT_TCP_PORTS" ] || { all_ok=0 - echo "Waiting for tcp services on $CTDB_WAIT_TCP_PORTS to come up" + echo "Waiting for local tcp ports $CTDB_WAIT_TCP_PORTS" while [ $all_ok -eq 0 ]; do all_ok=1 for p in $CTDB_WAIT_TCP_PORTS; do @@ -23,7 +23,24 @@ case $cmd in exit 1 } done - echo "Local tcp services on $CTDB_WAIT_TCP_PORTS are up" + echo "Local tcp services are up" + } + # wait for local directories to becomes available (could be slow to mount) + [ -z "$CTDB_WAIT_DIRECTORIES" ] || { + all_ok=0 + echo "Waiting for local directories $CTDB_WAIT_DIRECTORIES" + while [ $all_ok -eq 0 ]; do + all_ok=1 + for d in $CTDB_WAIT_DIRECTORIES; do + [ -d $d ] || all_ok=0 + done + [ $all_ok -eq 1 ] || sleep 1 + /usr/bin/ctdb status > /dev/null 2>&1 || { + echo "ctdb daemon has died. Exiting event startup" + exit 1 + } + done + echo "Local directories are available" } exit 0; ;; -- 2.47.3