From 7356491b1d364f717f27123363b9f8f831c9a3d5 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 27 Sep 2019 22:18:59 +0300 Subject: [PATCH] reworked permissions and added compression.... Signed-off-by: Alex A. Naanou --- scripts/sync-flash.sh | 81 ++++++++++++++----- .../archive/media/img/my/work/sync-flash.sh | 81 ++++++++++++++----- 2 files changed, 118 insertions(+), 44 deletions(-) diff --git a/scripts/sync-flash.sh b/scripts/sync-flash.sh index 596e4d51..c37d0ad1 100755 --- a/scripts/sync-flash.sh +++ b/scripts/sync-flash.sh @@ -5,7 +5,8 @@ COUNT=1 TITLE="" RSYNC=rsync -RSYNCFLAGS="-arptgoA --info=progress2,flist --human-readable" +#RSYNCFLAGS="-arptgoA --info=progress2,flist --human-readable" +RSYNCFLAGS="-arpt --info=progress2,flist --human-readable" CP=cp CPFLAGS=-Rpfv @@ -14,6 +15,10 @@ CPFLAGS=-Rpfv COPY=$RSYNC COPYFLAGS=$RSYNCFLAGS +COMPRESSOR=./compress-archive.sh +COMPRESS=1 + + # base mount dir... # systems with /mnt if [ -d /mnt ] ; then @@ -40,11 +45,20 @@ while true ; do echo " single shoot." echo " -l|-last last flash card in set, run" echo " process-archive.sh after copying." - echo " -b|-base the base dir to look for drives in" + echo " -b|-base BASE the base dir to look for drives in" echo " default: $BASE" echo " --rsync use rsync (default)" echo " --cp use cp" - # XXX add post-compression options... + if ! [ -z $COMPRESSOR ] ; then + echo " --compress toggle archive compression" + echo " default: `[[ $COMPRESS ]] && echo "on" || echo "off"`" + fi + # notes... + echo + if ! [ -z $COMPRESSOR ] ; then + echo "NOTE: the index is fully usable during the compression stage" + fi + echo "NOTE: cp under Cygwin may messup permissions, use rsync." echo exit ;; @@ -62,17 +76,24 @@ while true ; do shift ;; -b|-base|--base) - BASE=1 - shift + BASE=$2 + shift 2 ;; -cp|--cp) COPY=cp COPYFLAGS=-Rpfv + shift break ;; -rsync|--rsync) COPY=$RSYNC COPYFLAGS=$RSYNCFLAGS + shift + break + ;; + -compress|--compress) + COMPRESS=`[[ $COMPRESS ]] && echo "" || echo 1` + shift break ;; *) @@ -100,10 +121,12 @@ while true ; do echo "Enter) copy drive ${DRIVE}" fi echo "2) build." - # XXX compression... - #echo "3) compresion is `[[ $COMPRESS ]] && echo "on" || echo "off" `" - #echo "4) quit." - echo "3) quit." + if ! [ -z $COMPRESSOR ] ; then + echo "3) compresion is `[[ $COMPRESS ]] && echo "on" || echo "off"`" + echo "4) quit." + else + echo "3) quit." + fi read -p ": " RES case $RES in @@ -130,13 +153,15 @@ while true ; do LAST=1 break ;; -# 3) -# COMPRESS=`[[ ! $COMPRESS ]] && echo 1 || echo ""` -# continue -# ;; - -# 4) 3) + if ! [ -z $COMPRESSOR ] ; then + COMPRESS=`[[ ! $COMPRESS ]] && echo 1 || echo ""` + else + exit + fi + continue + ;; + 4) exit ;; @@ -147,6 +172,17 @@ while true ; do esac fi + # sanity check... + if ! [ -e "${BASE}/${DRIVE}" ] ; then + echo + echo "ERR: ${BASE}/${DRIVE}: does not exist, nothing to copy." + echo + if [[ $INTERACTIVE || ! $DRIVE ]] ; then + continue + fi + exit + fi + # XXX do a real three digit count... # single flash card... SCOUNT=`printf "%03d" $COUNT` @@ -196,12 +232,13 @@ if [[ ! $MULTI || $LAST ]] ; then echo "Building archive: done." fi - -# XXX post processing -- compress archive... -#if [[ $COMPRESS ]] ; then -# echo "Compressing archive..." -# ./compress-archive.sh "$BASE_DIR" -# echo "Compressing archive: done." -#fi +if [[ $COMPRESS ]] ; then + echo "Compressing archive..." + ${COMPRESSOR} "$BASE_DIR" + echo "Compressing archive: done." +fi +echo "`basename "$0"`: done." + +# vim:set nowrap : diff --git a/ui (gen4)/archive/media/img/my/work/sync-flash.sh b/ui (gen4)/archive/media/img/my/work/sync-flash.sh index 596e4d51..c37d0ad1 100755 --- a/ui (gen4)/archive/media/img/my/work/sync-flash.sh +++ b/ui (gen4)/archive/media/img/my/work/sync-flash.sh @@ -5,7 +5,8 @@ COUNT=1 TITLE="" RSYNC=rsync -RSYNCFLAGS="-arptgoA --info=progress2,flist --human-readable" +#RSYNCFLAGS="-arptgoA --info=progress2,flist --human-readable" +RSYNCFLAGS="-arpt --info=progress2,flist --human-readable" CP=cp CPFLAGS=-Rpfv @@ -14,6 +15,10 @@ CPFLAGS=-Rpfv COPY=$RSYNC COPYFLAGS=$RSYNCFLAGS +COMPRESSOR=./compress-archive.sh +COMPRESS=1 + + # base mount dir... # systems with /mnt if [ -d /mnt ] ; then @@ -40,11 +45,20 @@ while true ; do echo " single shoot." echo " -l|-last last flash card in set, run" echo " process-archive.sh after copying." - echo " -b|-base the base dir to look for drives in" + echo " -b|-base BASE the base dir to look for drives in" echo " default: $BASE" echo " --rsync use rsync (default)" echo " --cp use cp" - # XXX add post-compression options... + if ! [ -z $COMPRESSOR ] ; then + echo " --compress toggle archive compression" + echo " default: `[[ $COMPRESS ]] && echo "on" || echo "off"`" + fi + # notes... + echo + if ! [ -z $COMPRESSOR ] ; then + echo "NOTE: the index is fully usable during the compression stage" + fi + echo "NOTE: cp under Cygwin may messup permissions, use rsync." echo exit ;; @@ -62,17 +76,24 @@ while true ; do shift ;; -b|-base|--base) - BASE=1 - shift + BASE=$2 + shift 2 ;; -cp|--cp) COPY=cp COPYFLAGS=-Rpfv + shift break ;; -rsync|--rsync) COPY=$RSYNC COPYFLAGS=$RSYNCFLAGS + shift + break + ;; + -compress|--compress) + COMPRESS=`[[ $COMPRESS ]] && echo "" || echo 1` + shift break ;; *) @@ -100,10 +121,12 @@ while true ; do echo "Enter) copy drive ${DRIVE}" fi echo "2) build." - # XXX compression... - #echo "3) compresion is `[[ $COMPRESS ]] && echo "on" || echo "off" `" - #echo "4) quit." - echo "3) quit." + if ! [ -z $COMPRESSOR ] ; then + echo "3) compresion is `[[ $COMPRESS ]] && echo "on" || echo "off"`" + echo "4) quit." + else + echo "3) quit." + fi read -p ": " RES case $RES in @@ -130,13 +153,15 @@ while true ; do LAST=1 break ;; -# 3) -# COMPRESS=`[[ ! $COMPRESS ]] && echo 1 || echo ""` -# continue -# ;; - -# 4) 3) + if ! [ -z $COMPRESSOR ] ; then + COMPRESS=`[[ ! $COMPRESS ]] && echo 1 || echo ""` + else + exit + fi + continue + ;; + 4) exit ;; @@ -147,6 +172,17 @@ while true ; do esac fi + # sanity check... + if ! [ -e "${BASE}/${DRIVE}" ] ; then + echo + echo "ERR: ${BASE}/${DRIVE}: does not exist, nothing to copy." + echo + if [[ $INTERACTIVE || ! $DRIVE ]] ; then + continue + fi + exit + fi + # XXX do a real three digit count... # single flash card... SCOUNT=`printf "%03d" $COUNT` @@ -196,12 +232,13 @@ if [[ ! $MULTI || $LAST ]] ; then echo "Building archive: done." fi - -# XXX post processing -- compress archive... -#if [[ $COMPRESS ]] ; then -# echo "Compressing archive..." -# ./compress-archive.sh "$BASE_DIR" -# echo "Compressing archive: done." -#fi +if [[ $COMPRESS ]] ; then + echo "Compressing archive..." + ${COMPRESSOR} "$BASE_DIR" + echo "Compressing archive: done." +fi +echo "`basename "$0"`: done." + +# vim:set nowrap :