From 5cdc40bf3c28201a4e23e5a7c42774097ed0b8a2 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sat, 25 Oct 2014 12:36:24 +0200 Subject: [PATCH] Update. --- rsync-luks.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/rsync-luks.sh b/rsync-luks.sh index 1b244c2..672890b 100755 --- a/rsync-luks.sh +++ b/rsync-luks.sh @@ -20,7 +20,7 @@ set -e set -o pipefail -if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then +if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then cat < @@ -34,21 +34,21 @@ EOF exit 0 fi -[ -f "$1" ] && [ -f "$2" ] || (echo "$0 " >&2 && exit 1) +[[ -f "$1" ]] && [[ -f "$2" ]] || (echo "$0 " >&2 && exit 1) -[ -e "/dev/mapper/crypt-src" ] && (echo "/dev/mapper/crypt-src already exists." >&2 && exit 1) +[[ -e "/dev/mapper/crypt-src" ]] && (echo "/dev/mapper/crypt-src already exists." >&2 && exit 1) -[ -e "/dev/mapper/crypt-dst" ] && (echo "/dev/mapper/crypt-dst already exists." >&2 && exit 1) +[[ -e "/dev/mapper/crypt-dst" ]] && (echo "/dev/mapper/crypt-dst already exists." >&2 && exit 1) function exit_handler () { - [ -n "${VOL_SRC+yes}" ] && umount "${VOL_SRC}" && rmdir "${VOL_SRC}" && unset VOL_SRC - [ -e "/dev/mapper/crypt-src" ] && cryptsetup luksClose crypt-src - [ -n "${LOOP_SRC+yes}" ] && losetup -d "${LOOP_SRC}" && unset LOOP_SRC + [[ -n "${VOL_SRC+yes}" ]] && umount "${VOL_SRC}" && rmdir "${VOL_SRC}" && unset VOL_SRC + [[ -e "/dev/mapper/crypt-src" ]] && cryptsetup luksClose crypt-src + [[ -n "${LOOP_SRC+yes}" ]] && losetup -d "${LOOP_SRC}" && unset LOOP_SRC - [ -n "${VOL_DST+yes}" ] && umount "${VOL_DST}" && rmdir "${VOL_DST}" && unset VOL_DST - [ -e "/dev/mapper/crypt-dst" ] && cryptsetup luksClose crypt-dst - [ -n "${LOOP_DST+yes}" ] && losetup -d "${LOOP_DST}" && unset LOOP_DST + [[ -n "${VOL_DST+yes}" ]] && umount "${VOL_DST}" && rmdir "${VOL_DST}" && unset VOL_DST + [[ -e "/dev/mapper/crypt-dst" ]] && cryptsetup luksClose crypt-dst + [[ -n "${LOOP_DST+yes}" ]] && losetup -d "${LOOP_DST}" && unset LOOP_DST } @@ -61,7 +61,7 @@ LOOP_SRC="$(losetup -f)" losetup "${LOOP_SRC}" "$1" cryptsetup luksOpen "${LOOP_SRC}" crypt-src VOL_SRC="$(mktemp -d /tmp/sync-luks.XXXXXX)" -mount /dev/mapper/crypt-src "${VOL_SRC}" +mount -o ro /dev/mapper/crypt-src "${VOL_SRC}" LOOP_DST="$(losetup -f)" losetup "${LOOP_DST}" "$2" @@ -85,7 +85,7 @@ echo "* Press 'y' to synchronize, anything else to cancel." read -n 1 KEY -if [ "${KEY}" == "y" ]; then +if [[ "${KEY}" == "y" ]]; then rsync --itemize-changes --delete --progress -axz "${VOL_SRC}/" "${VOL_DST}/" else echo "No synchronization." -- 2.20.1