2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 if ! getargbool 1 rd.luks -n rd_NO_LUKS; then
5 info "rd.luks=0: removing cryptoluks activation"
6 rm -f /etc/udev/rules.d/70-luks.rules
9 echo 'SUBSYSTEM!="block", GOTO="luks_end"'
10 echo 'ACTION!="add|change", GOTO="luks_end"'
11 } > /etc/udev/rules.d/70-luks.rules.new
13 LUKS=$(getargs rd.luks.uuid rd_LUKS_UUID)
14 tout=$(getarg rd.luks.key.tout)
16 if [ -n "$LUKS" ]; then
17 for luksid in $LUKS; do
18 luksid=${luksid##luks-}
20 printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
21 printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
22 printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
23 printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask)
24 printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $tout
25 } >> /etc/udev/rules.d/70-luks.rules.new
28 [ -e $hookdir/initqueue/finished/90-crypt.sh ] || \
31 printf -- 'for dm in /dev/dm-*; do\n'
32 printf -- '[ -e "$dm" ] || exit 1\n'
33 printf -- 'dmid=`/sbin/dmsetup info -c -o uuid --noheadings "$dm"`\n'
34 printf -- 'uuid=${dmid#CRYPT-LUKS*-}\n'
35 printf -- '[ "x$uuid" = "x$dmid" ] && continue\n'
36 printf -- 'UUIDS="${UUIDS}${uuid%%%%-*}:"\n'
38 } > $hookdir/initqueue/finished/90-crypt.sh
40 while [ "$uuid" != "${uuid#*-}" ]; do uuid=${uuid%%-*}${uuid#*-}; done
41 printf -- '[ "x${UUIDS#*:%s*:}" != "x$UUIDS" ] || exit 1\n' $uuid >> $hookdir/initqueue/finished/90-crypt.sh
44 printf -- '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
45 printf -- 'warn "crypto LUKS UUID "%s" not found"\n' $luksid
46 } >> $hookdir/emergency/90-crypt.sh
50 printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue)
51 printf -- '--unique --onetime --name cryptroot-ask-%%k '
52 printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $(command -v cryptroot-ask) $tout
53 } >> /etc/udev/rules.d/70-luks.rules.new
56 echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules.new
57 mv /etc/udev/rules.d/70-luks.rules.new /etc/udev/rules.d/70-luks.rules