ctdb-scripts: Clean up ctdb_check_unix_socket()
authorMartin Schwenke <martin@meltin.net>
Sat, 18 Mar 2017 10:53:06 +0000 (21:53 +1100)
committerMartin Schwenke <martins@samba.org>
Tue, 12 Sep 2017 10:23:19 +0000 (12:23 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/functions

index 1131229ebb9f00ef8244c17993e0a5682878f81e..e31a095ab2743fb8f022bc9e152c801e4d0b3254 100755 (executable)
@@ -376,16 +376,21 @@ ctdb_check_tcp_ports()
 
 ######################################################
 # check a unix socket
-# usage: ctdb_check_unix_socket SERVICE_NAME <socket_path>
+# 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
 }
 
 ################################################