diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 00:31:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 00:31:19 +0000 |
commit | 6e33fee6f4a7e2041dd276995b402ca036fcab14 (patch) | |
tree | 85be5c41f2715d7d4d24cfa220197f1e2c778259 /misc/dracut_90reencrypt/parse-reencrypt.sh | |
parent | Initial commit. (diff) | |
download | cryptsetup-upstream/2%2.1.0.tar.xz cryptsetup-upstream/2%2.1.0.zip |
Adding upstream version 2:2.1.0.upstream/2%2.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'misc/dracut_90reencrypt/parse-reencrypt.sh')
-rwxr-xr-x | misc/dracut_90reencrypt/parse-reencrypt.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/misc/dracut_90reencrypt/parse-reencrypt.sh b/misc/dracut_90reencrypt/parse-reencrypt.sh new file mode 100755 index 0000000..5fec191 --- /dev/null +++ b/misc/dracut_90reencrypt/parse-reencrypt.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +REENC=$(getargs rd.luks.reencrypt=) +# shellcheck disable=SC2086 +REENC_DEV=$(echo $REENC | sed 's/:.*//') +# shellcheck disable=SC2086 +REENC_SIZE=$(echo $REENC | sed -n 's/.*://p') + +REENC_KEY=$(getargs rd.luks.reencrypt_key=) +if [ -z "$REENC_KEY" ] ; then + REENC_KEY=none +fi + +REENC_SLOT=$(getargs rd.luks.reencrypt_keyslot=) +if [ -z "$REENC_SLOT" ] ; then + REENC_SLOT=any +fi + +# shellcheck disable=SC2086 +# shellcheck disable=SC1004 +# shellcheck disable=SC2016 +if [ -n "$REENC_DEV" ] ; then +{ + printf 'SUBSYSTEM!="block", GOTO="reenc_end"\n' + printf 'ACTION!="add|change", GOTO="reenc_end"\n' + printf 'KERNEL=="%s", ' $REENC_DEV + printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue \ + --unique --onetime --settled --name crypt-reencrypt-%%k \ + /sbin/reencrypt $env{DEVNAME} %s"\n' "$REENC_KEY $REENC_SLOT $REENC_SIZE" + + printf 'ENV{ID_FS_UUID}=="*%s*", ' $REENC_DEV + printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue \ + --unique --onetime --settled --name crypt-reencrypt-%%k \ + /sbin/reencrypt $env{DEVNAME} %s"\n' "$REENC_KEY $REENC_SLOT $REENC_SIZE" + printf 'LABEL="reenc_end"\n' +} > /etc/udev/rules.d/69-reencryption.rules + initqueue --unique --finished --name crypt-reencrypt-finished-${REENC_DEV} [ -e /tmp/reencrypted ] +fi |