From e018547bb82fa4dce3baaa400d33294cb46a223d Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Tue, 22 Feb 2011 22:31:38 +0100 Subject: ftpsync fix bug in rsync speed statistic output in a case where, for whatever reason, the logfile has been rotated away before we try to grep around in it. also update copyright years. Signed-off-by: Joerg Jaspert --- bin/ftpsync | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/ftpsync b/bin/ftpsync index 139b884..cf75049 100755 --- a/bin/ftpsync +++ b/bin/ftpsync @@ -12,7 +12,7 @@ set -E # Based losely on a number of existing scripts, written by an # unknown number of different people over the years. # -# Copyright (C) 2008,2009,2010 Joerg Jaspert +# Copyright (C) 2008,2009,2010,2011 Joerg Jaspert # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -108,16 +108,17 @@ cleanup() { log "Mirrorsync done"; # Lets get a statistical value - SPEED=$( - SPEEDLINE=$(egrep '[0-9.]+ bytes/sec' ${LOGDIR}/rsync-${NAME}.log) - set "nothing" ${SPEEDLINE} - echo $8 - ) - if [ -n "${SPEED}" ]; then - SPEED=${SPEED%%.*} - SPEED=$(( $SPEED / 1024 )) - else - SPEED='unknown' + SPEED="unknown" + if [ -f "${LOGDIR}/rsync-${NAME}.log" ]; then + SPEED=$( + SPEEDLINE=$(egrep '[0-9.]+ bytes/sec' "${LOGDIR}/rsync-${NAME}.log") + set "nothing" ${SPEEDLINE} + echo $8 + ) + if [ -n "${SPEED}" ]; then + SPEED=${SPEED%%.*} + SPEED=$(( $SPEED / 1024 )) + fi fi log "Rsync transfer speed: ${SPEED} KB/s" -- cgit v1.2.3