From 26df6757ada617f423f653e114cfacfe40e607cd Mon Sep 17 00:00:00 2001 From: Eugene Paskevich Date: Tue, 6 May 2014 22:09:03 +0300 Subject: Revised trace file generation a bit. - Added an option to write the date only. - Added an option to change the hostname written into the trace file. - Open the new temporary trace file for writing only once. --- bin/ftpsync | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'bin/ftpsync') diff --git a/bin/ftpsync b/bin/ftpsync index c30563a..0aa7a17 100755 --- a/bin/ftpsync +++ b/bin/ftpsync @@ -281,7 +281,8 @@ TRACE=${TRACE:-"project/trace/${MIRRORNAME}"} # what it will be. # Possible values are # "full" - all information -# "terse" - basic, timestamp only (date -u) +# "terse" - partial, ftpsync version and local hostname +# "date" - basic, timestamp only (date -u) # "touch" - just touch the file in existance # "none" - no tracefile at all # @@ -608,26 +609,30 @@ if [ "xtruex" = "x${SYNCSTAGE2}x" ] || [ "xtruex" = "x${SYNCALL}x" ]; then log "Just touching the trace file" touch "${TO}/${TRACE}" ;; - terse|full) + date|terse|full) log "Creating a ${EXTENDEDTRACE} trace file" if [ -d "$(dirname "${TO}/${TRACE}")" ]; then - LC_ALL=POSIX LANG=POSIX date -u > "${TO}/${TRACE}.new" - echo "Used ftpsync version: ${VERSION}" >> "${TO}/${TRACE}.new" - echo "Running on host: $(hostname -f)" >> "${TO}/${TRACE}.new" - if [ "xfullx" = "x${EXTENDEDTRACE}x" ]; then - GLOBALARCHLIST="source amd64 armel armhf hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc" - - AEXCLUDE="^${ARCH_EXCLUDE// /\$|^}$" - ARCHLIST="" - for ARCH in ${GLOBALARCHLIST}; do - if ! [[ ${ARCH} =~ ${AEXCLUDE} ]]; then - ARCHLIST="${ARCHLIST} ${ARCH}" - fi - done - out="GUESSED:{${ARCHLIST}}" - echo "Architectures: ${out}" >> "${TO}/${TRACE}.new" - echo "Upstream-mirror: ${RSYNC_HOST}" >> "${TO}/${TRACE}.new" - fi # full trace + { + LC_ALL=POSIX LANG=POSIX date -u + if [ "xdatex" != "x${EXTENDEDTRACE}x" ]; then + echo "Used ftpsync version: ${VERSION}" + echo "Running on host: ${TRACEHOST:-$(hostname -f)}" + if [ "xfullx" = "x${EXTENDEDTRACE}x" ]; then + GLOBALARCHLIST="source amd64 armel armhf hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc" + + AEXCLUDE="^${ARCH_EXCLUDE// /\$|^}$" + ARCHLIST="" + for ARCH in ${GLOBALARCHLIST}; do + if ! [[ ${ARCH} =~ ${AEXCLUDE} ]]; then + ARCHLIST="${ARCHLIST} ${ARCH}" + fi + done + out="GUESSED:{${ARCHLIST}}" + echo "Architectures: ${out}" + echo "Upstream-mirror: ${RSYNC_HOST}" + fi # full trace + fi # other traces + } > "${TO}/${TRACE}.new" mv "${TO}/${TRACE}.new" "${TO}/${TRACE}" fi ;; -- cgit v1.2.3