summaryrefslogtreecommitdiffstats
path: root/ctdb/config/functions
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-10-17 15:23:35 +1100
committerAmitay Isaacs <amitay@gmail.com>2013-10-22 14:34:04 +1100
commit49d0153b10032640a6ab13d95a7c9d3b4cd3f64d (patch)
tree4d51aaa321c123fdf380e88241fe89c148f4c27b /ctdb/config/functions
parent0e9c939c0cfc9ed46373d527b50d75f43295dcc7 (diff)
downloadsamba-49d0153b10032640a6ab13d95a7c9d3b4cd3f64d.tar.gz
samba-49d0153b10032640a6ab13d95a7c9d3b4cd3f64d.tar.xz
samba-49d0153b10032640a6ab13d95a7c9d3b4cd3f64d.zip
eventscripts: Fold ctdb_check_tcp_ports_ctdb() into ctdb_check_tcp_ports()
A generic framework is no longer needed now that the "ctdb" checker is the only one left. Simplify the code. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 044d302b41a2040642355401e3236fcecc3a620a)
Diffstat (limited to 'ctdb/config/functions')
-rwxr-xr-xctdb/config/functions66
1 files changed, 16 insertions, 50 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 68259b934a0..ccf23bdf042 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -474,6 +474,8 @@ ctdb_check_tcp_init ()
touch "$_ctdb_service_started_file"
}
+# Check whether something is listening on all of the given TCP ports
+# using the "ctdb checktcpport" command.
ctdb_check_tcp_ports()
{
if [ -z "$1" ] ; then
@@ -481,75 +483,39 @@ ctdb_check_tcp_ports()
exit 1
fi
- # Set default value for CTDB_TCP_PORT_CHECKERS if unset.
- # If any of these defaults are unsupported then this variable can
- # be overridden in /etc/sysconfig/ctdb or via a file in
- # /etc/ctdb/rc.local.d/.
- : ${CTDB_TCP_PORT_CHECKERS:=ctdb}
-
- for _c in $CTDB_TCP_PORT_CHECKERS ; do
- ctdb_check_tcp_ports_$_c "$@"
- case "$?" in
+ for _p ; do # process each function argument (port)
+ _cmd="ctdb checktcpport $_p"
+ _out=$($_cmd 2>&1)
+ _ret=$?
+ case "$_ret" in
0)
_ctdb_check_tcp_common
- rm -f "$_ctdb_service_started_file"
- return 0
- ;;
- 1)
- _ctdb_check_tcp_common
if [ ! -f "$_ctdb_service_started_file" ] ; then
echo "ERROR: $service_name tcp port $_p is not responding"
- debug <<EOF
-$ctdb_check_tcp_ports_debug
-EOF
+ debug "\"ctdb checktcpport $_p\" was able to bind to port"
else
echo "INFO: $service_name tcp port $_p is not responding"
fi
return 1
;;
- 127)
- debug <<EOF
-ctdb_check_ports - checker $_c not implemented
-output from checker was:
-$ctdb_check_tcp_ports_debug
-EOF
- ;;
- *)
-
- esac
- done
-
- echo "INTERNAL ERROR: ctdb_check_ports - no working checkers in CTDB_TCP_PORT_CHECKERS=\"$CTDB_TCP_PORT_CHECKERS\""
-
- return 127
-}
-
-# Use the new "ctdb checktcpport" command to check the port.
-# This is very cheap.
-ctdb_check_tcp_ports_ctdb ()
-{
- for _p ; do # process each function argument (port)
- _cmd="ctdb checktcpport $_p"
- _out=$($_cmd 2>&1)
- _ret=$?
- case "$_ret" in
- 0)
- ctdb_check_tcp_ports_debug="\"$_cmd\" was able to bind to port"
- return 1
- ;;
98)
# Couldn't bind, something already listening, next port...
continue
;;
*)
- ctdb_check_tcp_ports_debug="$_cmd (exited with $_ret) with output:
+ echo "ERROR: unexpected error running \"ctdb checktcpport\""
+ debug <<EOF
+ctdb checktcpport (exited with $_ret) with output:
$_out"
- # assume not implemented
- return 127
+EOF
+ return $_ret
esac
done
+ # All ports listening
+ _ctdb_check_tcp_common
+ rm -f "$_ctdb_service_started_file"
return 0
}