]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
wait for local tcp services like smbd to come up before allowing ctdb to start talkin...
authorAndrew Tridgell <tridge@samba.org>
Wed, 30 May 2007 02:27:58 +0000 (12:27 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 30 May 2007 02:27:58 +0000 (12:27 +1000)
(This used to be ctdb commit 04eea084ebf1710ea66ccb03ac661e3b2f58d96f)

ctdb/common/ctdb_daemon.c
ctdb/tools/events

index 3248775519f4a937572c76b19a18d133d42e0c14..015b8a186812b5d9df3aa5e22fb679da5b1a90d6 100644 (file)
@@ -50,6 +50,12 @@ static void ctdb_main_loop(struct ctdb_context *ctdb)
                return;
        }
 
+       ret = ctdb_event_script(ctdb, "startup");
+       if (ret != 0) {
+               DEBUG(0,("Failed startup event script\n"));
+               return;
+       }
+
        /* start the transport running */
        if (ctdb->methods->start(ctdb) != 0) {
                DEBUG(0,("transport failed to start!\n"));
index 69f63a62aa4f45ee483ae8e2704606a5427bb64b..58aba9e319c85d78a86bb31757053690c80d1e7b 100755 (executable)
@@ -1,10 +1,28 @@
 #!/bin/sh
 # sample event script for ctdb
 
+. /etc/sysconfig/ctdb
+
 cmd="$1"
 shift
 
 case $cmd in 
+     startup)
+       # wait for local services to come up
+       [ -z "$CTDB_WAIT_TCP_PORTS" ] || {
+         all_ok=0
+         while [ $all_ok -eq 0 ]; do
+                 all_ok=1
+                 for p in $CTDB_WAIT_TCP_PORTS; do
+                     /usr/bin/nc -z 127.0.0.1 $p || all_ok=0
+                 done
+                 [ $all_ok -eq 1 ] || sleep 1
+          done
+         echo "Local services on $CTDB_WAIT_TCP_PORTS are up"
+       }
+       exit 0; 
+       ;;
+       
      takeip)
        if [ $# != 3 ]; then
           echo "must supply interface, IP and maskbits"
@@ -13,6 +31,7 @@ case $cmd in
        iface=$1
        ip=$2
        maskbits=$3
+
        /sbin/ip addr add $ip/$maskbits dev $iface || {
                 echo "Failed to add $ip/$maskbits on dev $iface"
                 exit 1