Skip to content

Commit

Permalink
Implement native/base process checks for FreeBSD
Browse files Browse the repository at this point in the history
  - Make rsync process checks OS-dependent
  - Use (BSD) netstat on FreeBSD (not lsof)
  • Loading branch information
Sp1l authored and Nirbhay Choubey committed Nov 21, 2016
1 parent f16ead5 commit cf1b0c1
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions scripts/wsrep_sst_rsync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,29 @@ check_pid_and_port()
local rsync_addr=$3
local rsync_port=$4

if ! which lsof > /dev/null; then
wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
exit 2 # ENOENT
fi
case $OS in
FreeBSD)
local port_info=$(netstat -46lp ${rsync_port} 2>/dev/null | \
grep ":${rsync_port}")
local is_rsync=$(echo $port_info | \
grep -w '[[:space:]]\+rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)
;;
*)
if ! which lsof > /dev/null; then
wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
exit 2 # ENOENT
fi

local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \
grep "(LISTEN)")
local is_listening_all=$(echo $port_info | \
grep "*:$rsync_port" 2>/dev/null)
local is_listening_addr=$(echo $port_info | \
grep "$rsync_addr:$rsync_port" 2>/dev/null)
local is_rsync=$(echo $port_info | \
grep -w '^rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)
local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \
grep "(LISTEN)")
local is_listening_all=$(echo $port_info | \
grep "*:$rsync_port" 2>/dev/null)
local is_listening_addr=$(echo $port_info | \
grep "$rsync_addr:$rsync_port" 2>/dev/null)
local is_rsync=$(echo $port_info | \
grep -w '^rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)
;;
esac

if [ ! -z "$is_listening_all" -o ! -z "$is_listening_addr" ]; then
if [ -z "$is_rsync" ]; then
Expand Down

0 comments on commit cf1b0c1

Please sign in to comment.