From fe9477450a96d0e731126375b523b229088d2b1e Mon Sep 17 00:00:00 2001 From: "Paul C. Buetow (mars.fritz.box)" Date: Fri, 20 Jun 2014 09:45:00 +0200 Subject: theoretically it also works with directories now --- src/netdiff | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/netdiff b/src/netdiff index 8c2d6b6..9bba61f 100755 --- a/src/netdiff +++ b/src/netdiff @@ -6,42 +6,48 @@ declare -r VERSION='VERSION_DEVEL' declare -i RC=0 -declare -r SERVER="${1}" ; shift -declare -r FILE="${1}" ; shift -declare -i PORT="${1}" ; shift +declare -r SERVER="${1}" ; shift +declare -r PATH="${1}" ; shift +declare -i PORT="${1}" ; shift usage () { cat < $TMPFILE +if [[ "${SERVER}" == "$(hostname)" || + "${SERVER}" == "$(hostname --fqdn)" ]]; then + tar -cf - . --directory "${PATH}" | + nc -l -p ${PORT} | + tar -xf - --directory ${TMPPATH} RC=$? else sleep 0.1 - nc ${SERVER} ${PORT} < "${FILE}" > $TMPFILE + tar -cf - . --directory "${PATH}" | + nc ${SERVER} ${PORT} | + tar -xf - --directory ${TMPPATH} RC=$? fi -if [ $RC -ne 0 ]; then +if [ ${RC} -ne 0 ]; then echo 'Could not copy file via the network' RC=2 # Default trouble exit status of diff else - diff $@ ${FILE} ${TMPFILE} ${DIFF_DEFAULT_OPTS} + diff $@ "${PATH}" ${TMPPATH} ${DIFF_DEFAULT_OPTS} RC=$? fi -[ -f $TMPFILE ] && rm $TMPFILE -exit $RC +[ -f ${TMPPATH} ] && rm -rf ${TMPPATH} +exit ${RC} -- cgit v1.2.3