diff options
-rwxr-xr-x | ctdb/config/events.d/50.samba | 3 | ||||
-rw-r--r-- | ctdb/config/functions | 26 |
2 files changed, 27 insertions, 2 deletions
diff --git a/ctdb/config/events.d/50.samba b/ctdb/config/events.d/50.samba index 0c48252a76..df2d8b23cd 100755 --- a/ctdb/config/events.d/50.samba +++ b/ctdb/config/events.d/50.samba @@ -30,6 +30,9 @@ case $cmd in # wait for the Samba tcp ports to become available smb_ports=`testparm -sv 2> /dev/null | egrep '\s*smb ports =' | cut -d= -f2` ctdb_wait_tcp_ports "Samba" $smb_ports + + # wait for winbind to be ready + ctdb_wait_command "winbind" "wbinfo -p" ;; takeip) diff --git a/ctdb/config/functions b/ctdb/config/functions index 4219f22383..ce292bc5fe 100644 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -26,6 +26,28 @@ service() { fi } + +###################################################### +# wait for a command to return a zero exit status +# usage: ctdb_wait_command SERVICE_NAME <command> +###################################################### +ctdb_wait_command() { + service_name="$1" + wait_cmd="$2" + [ -z "$wait_cmd" ] && return; + all_ok=0 + echo "`/bin/date` Waiting for service $service_name to start" + while [ $all_ok -eq 0 ]; do + $wait_cmd > /dev/null 2>&1 && all_ok=1 + ctdb status > /dev/null 2>&1 || { + echo "ctdb daemon has died. Exiting wait for $service_name" + exit 1 + } + done + echo "`/bin/date` Local service $service_name is up" +} + + ###################################################### # wait for a set of tcp ports # usage: ctdb_wait_tcp_ports SERVICE_NAME <ports...> @@ -50,7 +72,7 @@ ctdb_wait_tcp_ports() { fi done [ $all_ok -eq 1 ] || sleep 1 - /usr/bin/ctdb status > /dev/null 2>&1 || { + ctdb status > /dev/null 2>&1 || { echo "ctdb daemon has died. Exiting tcp wait $service_name" exit 1 } @@ -77,7 +99,7 @@ ctdb_wait_directories() { [ -d $d ] || all_ok=0 done [ $all_ok -eq 1 ] || sleep 1 - /usr/bin/ctdb status > /dev/null 2>&1 || { + ctdb status > /dev/null 2>&1 || { echo "ctdb daemon has died. Exiting directory wait for $service_name" exit 1 } |