From ff635f90edd8e012ac2838303cb0285ab09b8db6 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Sat, 18 Mar 2017 21:53:06 +1100 Subject: [PATCH] ctdb-scripts: Clean up ctdb_check_unix_socket() Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/config/functions | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ctdb/config/functions b/ctdb/config/functions index 1131229ebb9..e31a095ab27 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -376,16 +376,21 @@ ctdb_check_tcp_ports() ###################################################### # check a unix socket -# usage: ctdb_check_unix_socket SERVICE_NAME +# usage: ctdb_check_unix_socket SOCKPATH ###################################################### -ctdb_check_unix_socket() { - socket_path="$1" - [ -z "$socket_path" ] && return +ctdb_check_unix_socket() +{ + _sockpath="$1" - if ! netstat --unix -a -n | grep -q "^unix.*LISTEN.*${socket_path}$"; then - echo "ERROR: $service_name socket $socket_path not found" - return 1 - fi + if [ -z "$_sockpath" ] ; then + echo "ERROR: ctdb_check_unix_socket() requires socket path" + return 1 + fi + + if ! netstat --unix -a -n | grep -q "^unix.*LISTEN.*${_sockpath}$"; then + echo "ERROR: ${service_name} not listening on ${_sockpath}" + return 1 + fi } ################################################ -- 2.11.4.GIT