refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-03-08 16:54:37 +03:00
parent 23509bacc1
commit 79e6fe4eb4

View File

@ -18,12 +18,14 @@ COPY=$RSYNC
COPYFLAGS=$RSYNCFLAGS COPYFLAGS=$RSYNCFLAGS
# NOTE: jdupes reports progress to stderr and output to stdout... # NOTE: jdupes reports progress to stderr and output to stdout...
# XXX need to test if this exists...
VERIFY=jdupes VERIFY=jdupes
VERIFYFLAGS="-r -u -I" VERIFYFLAGS="-r -u -I"
DO_VERIFY=1
COMPRESSOR=./compress-archive.sh COMPRESS=./compress-archive.sh
COMPRESS=1 DO_COMPRESS=1
# Config file to contain all the default settings... # Config file to contain all the default settings...
@ -68,15 +70,15 @@ while true ; do
echo " --cp use cp" echo " --cp use cp"
if ! [ -z $VERIFY ] ; then if ! [ -z $VERIFY ] ; then
echo " --verify toggle copy verification" echo " --verify toggle copy verification"
echo " default: `[[ $SKIP_VERIFY ]] && echo "off" || echo "on"`" echo " default: `[[ $DO_VERIFY ]] && echo "on" || echo "off"`"
fi fi
if ! [ -z $COMPRESSOR ] ; then if ! [ -z $COMPRESS ] ; then
echo " --compress toggle archive compression" echo " --compress toggle archive compression"
echo " default: `[[ $COMPRESS ]] && echo "on" || echo "off"`" echo " default: `[[ $DO_COMPRESS ]] && echo "on" || echo "off"`"
fi fi
# notes... # notes...
echo echo
if ! [ -z $COMPRESSOR ] ; then if ! [ -z $COMPRESS ] ; then
echo "NOTE: the index is fully usable during the compression stage" echo "NOTE: the index is fully usable during the compression stage"
fi fi
echo "NOTE: cp under Cygwin may messup permissions, use rsync." echo "NOTE: cp under Cygwin may messup permissions, use rsync."
@ -113,12 +115,12 @@ while true ; do
break break
;; ;;
-verify|--verify) -verify|--verify)
SKIP_VERIFY=`[[ $SKIP_VERIFY ]] && echo "" || echo 1` DO_VERIFY=`[[ $DO_VERIFY ]] && echo "" || echo 1`
shift shift
break break
;; ;;
-compress|--compress) -compress|--compress)
COMPRESS=`[[ $COMPRESS ]] && echo "" || echo 1` DO_COMPRESS=`[[ $DO_COMPRESS ]] && echo "" || echo 1`
shift shift
break break
;; ;;
@ -162,14 +164,14 @@ while true ; do
i=3 i=3
OPTION_VERIFICATION= OPTION_VERIFICATION=
if ! [ -z $VERIFY ] ; then if ! [ -z $VERIFY ] ; then
echo "$i) Verification is `[[ $SKIP_VERIFY ]] && echo "off" || echo "on"`" echo "$i) Verification is `[[ $DO_VERIFY ]] && echo "on" || echo "off"`"
OPTION_VERIFICATION=$i OPTION_VERIFICATION=$i
i=$(( i + 1 )) i=$(( i + 1 ))
fi fi
OPTION_COMPRESSION= OPTION_COMPRESSION=
if ! [ -z $COMPRESSOR ] ; then if ! [ -z $COMPRESS ] ; then
echo "$i) Compresion is `[[ $COMPRESS ]] && echo "on" || echo "off"`" echo "$i) Compresion is `[[ $DO_COMPRESS ]] && echo "on" || echo "off"`"
OPTION_COMPRESSION=$i OPTION_COMPRESSION=$i
i=$(( i + 1 )) i=$(( i + 1 ))
fi fi
@ -211,11 +213,11 @@ while true ; do
# dynamic option handlers... # dynamic option handlers...
"$OPTION_VERIFICATION") "$OPTION_VERIFICATION")
SKIP_VERIFY=`[[ ! $SKIP_VERIFY ]] && echo 1 || echo ""` DO_VERIFY=`[[ ! $DO_VERIFY ]] && echo 1 || echo ""`
continue continue
;; ;;
"$OPTION_COMPRESSION") "$OPTION_COMPRESSION")
COMPRESS=`[[ ! $COMPRESS ]] && echo 1 || echo ""` DO_COMPRESS=`[[ ! $DO_COMPRESS ]] && echo 1 || echo ""`
continue continue
;; ;;
"$OPTION_QUIT") "$OPTION_QUIT")
@ -292,7 +294,7 @@ while true ; do
# verify copy... # verify copy...
# XXX make this more generic... # XXX make this more generic...
if ! [ $SKIP_VERIFY ] && ! [ -z $VERIFY ] ; then if [ $DO_VERIFY ] && ! [ -z $VERIFY ] ; then
echo "Verifying copied files..." echo "Verifying copied files..."
$VERIFY $VERIFYFLAGS ${BASE}${DRIVE}/* "$DIR" \ $VERIFY $VERIFYFLAGS ${BASE}${DRIVE}/* "$DIR" \
> >(tee "${DIR}"/verification-err.log) > >(tee "${DIR}"/verification-err.log)
@ -342,9 +344,9 @@ if [[ ! $MULTI || $LAST ]] ; then
echo "Building archive: done." echo "Building archive: done."
fi fi
if [[ $COMPRESS ]] ; then if [[ $DO_COMPRESS ]] ; then
echo "Compressing archive..." echo "Compressing archive..."
${COMPRESSOR} "$BASE_DIR" ${COMPRESS} "$BASE_DIR"
echo "Compressing archive: done." echo "Compressing archive: done."
fi fi