#!/bin/sh # ctdb event script for Netbios Name Services check_tcp_ports() { if [ -z "$1" ]; then echo "INTERNAL ERROR: ctdb_check_tcp_ports - no ports specified" exit 1 fi for _p; do # process each function argument (port) _cmd="/usr/bin/ctdb checktcpport $_p" _out=$($_cmd 2>&1) _ret=$? case "$_ret" in 0) echo "$service_name not listening on TCP port $_p" return 1 ;; 98) # Couldn't bind, something already listening, next port continue ;; *) echo "unexpected error (${_ret}) running \"${_cmd}\"" if [ -n "$_out" ]; then echo "$_out" fi return $_ret ;; esac done # All ports listening return 0 } ############################## case "$1" in startup) supervisorctl start smbd_ctdb ;; shutdown) supervisorctl stop smbd_ctdb ;; monitor) check_tcp_ports 445 || exit $? ;; esac exit 0