mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
dff9a6ecd1
(This used to be ctdb commit 9521e3eee42b11303a2d6e0f5c05d0c0de4292d8)
62 lines
1.7 KiB
Plaintext
62 lines
1.7 KiB
Plaintext
# utility functions for ctdb event scripts
|
|
|
|
|
|
######################################################
|
|
# wait for a set of tcp ports
|
|
# usage: ctdb_wait_tcp_ports SERICE_NAME <ports...>
|
|
######################################################
|
|
ctdb_wait_tcp_ports() {
|
|
service_name="$1"
|
|
shift
|
|
wait_ports="$*"
|
|
[ -z "$wait_ports" ] && return;
|
|
all_ok=0
|
|
echo "`/bin/date` Waiting for tcp service $service_name to start"
|
|
while [ $all_ok -eq 0 ]; do
|
|
all_ok=1
|
|
for p in $wait_ports; do
|
|
if [ -x /usr/bin/netcat ]; then
|
|
/usr/bin/netcat -z 127.0.0.1 $p || all_ok=0
|
|
elif [ -x /usr/bin/nc ]; then
|
|
/usr/bin/nc -z 127.0.0.1 $p || all_ok=0
|
|
else
|
|
echo "`date` netcat not found - cannot check tcp ports"
|
|
return
|
|
fi
|
|
done
|
|
[ $all_ok -eq 1 ] || sleep 1
|
|
/usr/bin/ctdb status > /dev/null 2>&1 || {
|
|
echo "ctdb daemon has died. Exiting tcp wait $service_name"
|
|
exit 1
|
|
}
|
|
done
|
|
echo "`/bin/date` Local tcp services for $service_name are up"
|
|
}
|
|
|
|
|
|
######################################################
|
|
# wait for a set of directories
|
|
# usage: ctdb_wait_directories SERICE_NAME <directories...>
|
|
######################################################
|
|
ctdb_wait_directories() {
|
|
service_name="$1"
|
|
shift
|
|
wait_dirs="$*"
|
|
[ -z "$wait_dirs" ] && return;
|
|
all_ok=0
|
|
echo "`/bin/date` Waiting for local directories for $service_name"
|
|
while [ $all_ok -eq 0 ]; do
|
|
all_ok=1
|
|
for d in $wait_dirs; 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 directory wait for $service_name"
|
|
exit 1
|
|
}
|
|
done
|
|
echo "`/bin/date` Local directories for $service_name are available"
|
|
}
|
|
|