4 if [ ! -e /run
/zfs_fs_name
]; then
5 echo "Wait for the root pool to be imported or press Ctrl-C to exit."
7 while [ ! -e /run
/zfs_fs_name
]; do
8 if [ -e /run
/zfs_unlock_complete
]; then
14 echo "Unlocking encrypted ZFS filesystems..."
15 echo "Enter the password or press Ctrl-C to exit."
18 if [ ! -e /run
/zfs_unlock_complete_notify
]; then
19 mkfifo /run
/zfs_unlock_complete_notify
21 while [ ! -e /run
/zfs_unlock_complete
]; do
22 zfs_fs_name
=$
(cat /run
/zfs_fs_name
)
23 zfs_console_askpwd_cmd
=$
(cat /run
/zfs_console_askpwd_cmd
)
24 systemd-ask-password
"Encrypted ZFS password for ${zfs_fs_name}:" | \
25 /sbin
/zfs load-key
"$zfs_fs_name" || true
26 if [ "$(/sbin/zfs get -H -ovalue keystatus "$zfs_fs_name" 2> /dev/null)" = "available" ]; then
27 echo "Password for $zfs_fs_name accepted."
28 zfs_console_askpwd_pid
=$
(ps |
awk '!'"/awk/ && /$zfs_console_askpwd_cmd/ { print \$1; exit }")
29 if [ -n "$zfs_console_askpwd_pid" ]; then
30 kill "$zfs_console_askpwd_pid"
32 # Wait for another filesystem to unlock.
33 while [ "$(cat /run/zfs_fs_name)" = "$zfs_fs_name" ] && [ ! -e /run
/zfs_unlock_complete
]; do
37 echo "Wrong password. Try again."
40 echo "Unlocking complete. Resuming boot sequence..."
41 echo "Please reconnect in a while."
42 echo "ok" > /run
/zfs_unlock_complete_notify