[main]
@type = oneshot
@version = @vers@
@description = "Activate encrypted devices"
@user = ( root )
@depends = ( udevd devices-dmraid devices-lvm devices-mdraid )

[start]
@execute =
(
    if { 66-yeller -cdp devices-crypttab -1 /dev/console decrypt volumes }
    ifelse { blkid -c /dev/null --match-token=TYPE="crypto_LUKS" }

    {
    ifelse { execl-toc -X -e ${script_conf} }
        { if -nt {
            if { execl-cmdline -s { 66-olexec awk -f ${script_file} ${script_conf} } }
            foreground {

            if { blkid --match-token=TYPE="LVM2_member" }
            if { 66-which -q vgchange }
            if { 66-yeller -cdp devices-crypttab -1 /dev/console Activating LVM devices for dm-crypt... }
            if -nt {

                vgchange --sysinit -a ay
            }
            66-yeller -cdp devices-crypttab -1 /dev/console unable to activate LVM devices
        }
    }
    66-yeller -fcdp devices-crypttab -1 /dev/console crashed! }
    if { 66-yeller -cdp device-crypttab -1 /dev/console no ${script_conf} available, check your installation and configuration! } exit 0 }

    66-yeller -cdp device-crypttab -1 /dev/console no encrypted volumes available!
)

[environment]
script_file=!@scripts@/crypt.awk
script_conf=!/etc/crypttab

[logger]
@destination = @live_dir@/log/devices-crypttab