summaryrefslogtreecommitdiff
path: root/scripts/wsrep_sst_rsync.sh
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2016-11-08 08:35:57 -0500
committerNirbhay Choubey <nirbhay@mariadb.com>2016-11-21 15:38:33 -0500
commit44ccb8f29ea82d913ec1b55b61c8bbc7c64738a5 (patch)
tree3700138bb76974399ba7d04cfe672ce9c922b751 /scripts/wsrep_sst_rsync.sh
parentcf1b0c1ace3584fcd807e0643d30956baa5de2c2 (diff)
downloadmariadb-git-44ccb8f29ea82d913ec1b55b61c8bbc7c64738a5.tar.gz
MDEV-10432: Post-fix after merging PR#205
Diffstat (limited to 'scripts/wsrep_sst_rsync.sh')
-rw-r--r--scripts/wsrep_sst_rsync.sh49
1 files changed, 28 insertions, 21 deletions
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index b97cd0dd8a3..9e3d9560807 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -65,28 +65,29 @@ check_pid_and_port()
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)
+ local port_info="$(sockstat -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_rsync="$(echo $port_info | \
+ grep -w '^rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)"
;;
esac
+ 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)"
+
if [ ! -z "$is_listening_all" -o ! -z "$is_listening_addr" ]; then
if [ -z "$is_rsync" ]; then
wsrep_log_error "rsync daemon port '$rsync_port' has been taken"
@@ -202,7 +203,9 @@ then
if ! [ -z $WSREP_SST_OPT_BINLOG ]
then
# Prepare binlog files
- pushd $BINLOG_DIRNAME &> /dev/null
+ OLD_PWD="$(pwd)"
+ cd $BINLOG_DIRNAME
+
binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
binlog_files=""
for ii in $binlog_files_full
@@ -214,14 +217,14 @@ then
wsrep_log_info "Preparing binlog files for transfer:"
tar -cvf $BINLOG_TAR_FILE $binlog_files >&2
fi
- popd &> /dev/null
+ cd "$OLD_PWD"
fi
# first, the normal directories, so that we can detect incompatible protocol
RC=0
- rsync --owner --group --perms --links --specials \
+ eval rsync --owner --group --perms --links --specials \
--ignore-times --inplace --dirs --delete --quiet \
- $WHOLE_FILE_OPT "${FILTER}" "$WSREP_SST_OPT_DATA/" \
+ $WHOLE_FILE_OPT ${FILTER} "$WSREP_SST_OPT_DATA/" \
rsync://$WSREP_SST_OPT_ADDR >&2 || RC=$?
if [ "$RC" -ne 0 ]; then
@@ -253,7 +256,8 @@ then
fi
# then, we parallelize the transfer of database directories, use . so that pathconcatenation works
- pushd "$WSREP_SST_OPT_DATA" >/dev/null
+ OLD_PWD="$(pwd)"
+ cd $WSREP_SST_OPT_DATA
count=1
[ "$OS" = "Linux" ] && count=$(grep -c processor /proc/cpuinfo)
@@ -266,7 +270,7 @@ then
$WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \
rsync://$WSREP_SST_OPT_ADDR/{} >&2 || RC=$?
- popd >/dev/null
+ cd "$OLD_PWD"
if [ $RC -ne 0 ]; then
wsrep_log_error "find/rsync returned code $RC:"
@@ -377,7 +381,9 @@ EOF
if ! [ -z $WSREP_SST_OPT_BINLOG ]
then
- pushd $BINLOG_DIRNAME &> /dev/null
+ OLD_PWD="$(pwd)"
+ cd $BINLOG_DIRNAME
+
if [ -f $BINLOG_TAR_FILE ]
then
# Clean up old binlog files first
@@ -389,7 +395,8 @@ EOF
echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
done
fi
- popd &> /dev/null
+ cd "$OLD_PWD"
+
fi
if [ -r "$MAGIC_FILE" ]
then