"Fossies" - the Fresh Open Source Software Archive

Member "cryptsetup-2.4.3/misc/dracut_90reencrypt/parse-reencrypt.sh" (24 Jul 2021, 1322 Bytes) of package /linux/misc/cryptsetup-2.4.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 REENC=$(getargs rd.luks.reencrypt=)
    4 # shellcheck disable=SC2086
    5 REENC_DEV=$(echo $REENC | sed 's/:.*//')
    6 # shellcheck disable=SC2086
    7 REENC_SIZE=$(echo $REENC | sed -n 's/.*://p')
    8 
    9 REENC_KEY=$(getargs rd.luks.reencrypt_key=)
   10 if [ -z "$REENC_KEY" ] ; then
   11     REENC_KEY=none
   12 fi
   13 
   14 REENC_SLOT=$(getargs rd.luks.reencrypt_keyslot=)
   15 if [ -z "$REENC_SLOT" ] ; then
   16     REENC_SLOT=any
   17 fi
   18 
   19 # shellcheck disable=SC2086
   20 # shellcheck disable=SC1004
   21 # shellcheck disable=SC2016
   22 if [ -n "$REENC_DEV" ] ; then
   23 {
   24    printf 'SUBSYSTEM!="block", GOTO="reenc_end"\n'
   25    printf 'ACTION!="add|change", GOTO="reenc_end"\n'
   26    printf 'KERNEL=="%s", ' $REENC_DEV
   27    printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue \
   28            --unique --onetime --settled --name crypt-reencrypt-%%k \
   29            /sbin/reencrypt $env{DEVNAME} %s"\n' "$REENC_KEY $REENC_SLOT $REENC_SIZE"
   30 
   31    printf 'ENV{ID_FS_UUID}=="*%s*", ' $REENC_DEV
   32    printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue \
   33            --unique --onetime --settled --name crypt-reencrypt-%%k \
   34            /sbin/reencrypt $env{DEVNAME} %s"\n' "$REENC_KEY $REENC_SLOT $REENC_SIZE"
   35    printf 'LABEL="reenc_end"\n'
   36 } > /etc/udev/rules.d/69-reencryption.rules
   37    initqueue --unique --finished --name crypt-reencrypt-finished-${REENC_DEV} [ -e /tmp/reencrypted ]
   38 fi