-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac4cbc7
commit 8165d5c
Showing
1 changed file
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
#!/bin/bash | ||
|
||
( | ||
command -v zfs > /dev/null|| exit -1 | ||
command -v clevis > /dev/null || exit -1 | ||
|
||
echo "##### Unlocking ZFS encrypted volumes" | ||
|
||
while read -u 3 ds enc key | ||
while read -u 3 ds enc keystatus key | ||
do | ||
if [ "${enc}" != "off" -a "${key}" != "-" ] | ||
then | ||
echo "Loading key for ${ds}" | ||
if (echo -n "${key}" | clevis decrypt | zfs load-key -L prompt "${ds}") | ||
if [ "${keystatus}" = "available" ] | ||
then | ||
echo "Dataset ${ds} unlocked" | ||
echo "Dataset ${ds} already unlocked" | ||
else | ||
echo "FAILED TO UNLOCK ${ds}" | ||
echo "Loading key for ${ds}" | ||
if (echo -n "${key}" | clevis decrypt | zfs load-key -L prompt "${ds}") | ||
then | ||
echo "Dataset ${ds} unlocked" | ||
else | ||
echo "FAILED TO UNLOCK ${ds}" | ||
fi | ||
fi | ||
fi | ||
done 3< <(zfs list -H -o name,encryption,zfs-clevis:key) | ||
done 3< <(zfs list -H -o name,encryption,keystatus,zfs-clevis:key) | ||
) 1>&2 |