Imported Upstream version 2.3.3
[platform/upstream/cryptsetup.git] / misc / dracut_90reencrypt / reencrypt.sh
index c82f27e..db09e64 100755 (executable)
@@ -18,7 +18,7 @@ else
     device="$1"
 fi
 
-PARAMS="$device -T 1 --use-fsync -B 32"
+PARAMS="$device -T 1 --use-fsync --progress-frequency 5 -B 32"
 if [ "$3" != "any" ]; then
     PARAMS="$PARAMS -S $3"
 fi
@@ -28,30 +28,33 @@ if [ -n "$4" ]; then
 fi
 
 reenc_readkey() {
-    local keypath="${1#*:}"
-    local keydev="${1%%:*}"
+    keypath="${1#*:}"
+    keydev="${1%%:*}"
 
-    local mntp="/tmp/reencrypted-mount-tmp"
+    mntp="/tmp/reencrypted-mount-tmp"
     mkdir "$mntp"
     mount -r "$keydev" "$mntp" && cat "$mntp/$keypath"
     umount "$mntp"
     rm -r "$mntp"
 }
 
+# shellcheck disable=SC2086
+# shellcheck disable=SC2164
 reenc_run() {
-    local cwd=$(pwd)
-    local _prompt="LUKS password for REENCRYPTING $device"
+    cwd=$(pwd)
+    _prompt="LUKS password for REENCRYPTING $device"
     cd /tmp
+    udevadm settle
     if [ "$1" = "none" ] ; then
        if [ "$2" != "any" ]; then
                _prompt="$_prompt, using keyslot $2"
        fi
         /bin/plymouth ask-for-password \
         --prompt "$_prompt" \
-        --command="/sbin/cryptsetup-reencrypt $PARAMS"
+        --command="/sbin/cryptsetup-reencrypt-verbose $PARAMS"
     else
         info "REENCRYPT using key $1"
-        reenc_readkey "$1" | /sbin/cryptsetup-reencrypt -d - $PARAMS
+        reenc_readkey "$1" | /sbin/cryptsetup-reencrypt-verbose -d - $PARAMS
     fi
     _ret=$?
     cd $cwd
@@ -59,12 +62,14 @@ reenc_run() {
 
 info "REENCRYPT $device requested"
 # flock against other interactive activities
+# shellcheck disable=SC2086
 { flock -s 9;
     reenc_run $2 $3
 } 9>/.console_lock
 
 if [ $_ret -eq 0 ]; then
     # do not ask again
+    # shellcheck disable=SC2188
     >> /tmp/reencrypted
     warn "Reencryption of device $device has finished successfully. Use previous"
     warn "initramfs image (without reencrypt module) to boot the system. When"