Add initramfs compliant zlevis-fetch.
This commit is contained in:
parent
5bb178349f
commit
2b5f370781
1 changed files with 25 additions and 0 deletions
25
src/zlevis-fetch
Normal file
25
src/zlevis-fetch
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Exit immediately if a command exits with a non-zero status
|
||||
set -e
|
||||
|
||||
# Check if zlevis-decrypt is present
|
||||
command -v zlevis-decrypt > /dev/null || exit 1
|
||||
|
||||
# Read ZFS dataset information.
|
||||
zfs list -Ho name,encryption,keystatus,encryptionroot,tpm:jwe | while IFS=$'\t' read -r ds enc keystatus encroot jwe; do
|
||||
# Check if the dataset is the encryption root.
|
||||
if [ "$ds" = "$encroot" ] && [ "$enc" != "off" ] && [ "$key" != "-" ]; then
|
||||
if [ "$keystatus" = "available" ]; then
|
||||
echo "Pool $ds already unlocked"
|
||||
else
|
||||
echo "Loading key for $ds"
|
||||
if echo -n "$jwe" | zlevis-decrypt | zfs load-key -L prompt "$ds"; then
|
||||
echo "Unlocked $ds"
|
||||
else
|
||||
echo "FAILED TO UNLOCK $ds" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue