From f857c6e456365f2ad27c7bed9b1a2a5a1953420e Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 6 Mar 2024 16:47:11 +0300 Subject: [PATCH] a bit more paranoid virification... Signed-off-by: Alex A. Naanou --- .../archive/media/img/my/work/sync-flash.sh | 57 ++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/Viewer/archive/media/img/my/work/sync-flash.sh b/Viewer/archive/media/img/my/work/sync-flash.sh index 1a4294ac..2bb2867a 100755 --- a/Viewer/archive/media/img/my/work/sync-flash.sh +++ b/Viewer/archive/media/img/my/work/sync-flash.sh @@ -16,6 +16,9 @@ CPFLAGS=-Rpfv # override default... COPY=$RSYNC COPYFLAGS=$RSYNCFLAGS +VERIFY=$RSYNC +VERIFYFLAGS=-n $RSYNCFLAGS + COMPRESSOR=./compress-archive.sh COMPRESS=1 @@ -254,15 +257,53 @@ while true ; do mkdir -vp "$DIR" - echo "Copying files from ${BASE}${DRIVE} (~`du -hs "${BASE}${DRIVE}" | cut -f 1`)..." - $COPY $COPYFLAGS ${BASE}${DRIVE}/* "$DIR" \ - 2> >(tee "${DIR}"/copy-err.log) - # no errors -> remove log... - if ! [ -s "${DIR}/copy-err.log" ] ; then - rm -f "${DIR}"/copy-err.log - fi - echo "Copying files: done." + while true ; do + echo "Copying files from ${BASE}${DRIVE} (~`du -hs "${BASE}${DRIVE}" | cut -f 1`)..." + $COPY $COPYFLAGS ${BASE}${DRIVE}/* "$DIR" \ + 2> >(tee "${DIR}"/copy-err.log) + # no errors -> remove log... + if ! [ -s "${DIR}/copy-err.log" ] ; then + rm -f "${DIR}"/copy-err.log + fi + echo "Copying files: done." + # verify copy... + # XXX make this more generic... + if ! [ -z $VERIFY ] ; then + echo "Verifying copied files..." + $VERIFY $VERIFYFLAGS ${BASE}${DRIVE}/* "$DIR" \ + > >(tee "${DIR}"/verification-err.log) + if ! [ -s "${DIR}/verification-err.log" ] ; then + rm -f "${DIR}"/verification-err.log + else + echo + echo "WARNING: found mismatching files" + echo " (see: "${DIR}"/verification-err.log)" + echo + while true; do + read -ep "[R]etry, [C]ontinue, or Ctrl-C to cancel: " ACTION + ACTION=`echo ${ACTION,,} | xargs` + if [[ $ACTION =~ [rc] ]] ; then + break + fi + echo "Unknown input: \"$ACTION\"" + done + case ${ACTION} in + r) + continue + ;; + c) + break + ;; + esac + fi + echo "Verifification: done." + break + # no verification defined... + else + break + fi + done # exit interactive mode... if [[ ! $MULTI || ! $INTERACTIVE || $LAST ]] ; then