src/zlevis: specified options

This commit is contained in:
Luc Bijl 2025-02-14 21:22:52 +01:00
parent 44e6d7efd0
commit f022b1fe3c

View file

@ -15,21 +15,23 @@ fi
# Display usage information if input is from a terminal
if [ -t 0 ]; then
exec >&2
echo "Usage: zlevis {decrypt|encrypt} {pool|*} [options]"
echo "Usage: \"zlevis {decrypt|encrypt} {pool|key} [options]\""
exit 2
fi
case "$1" in
decrypt)
case "$2" in
case "$2" in
pool) zfs list -Ho tpm:jwe $3 | zlevis-decrypt;;
*) zlevis-decrypt $2;;
key) zlevis-decrypt;;
*) exit 1;;
esac
;;
encrypt)
case "$2" in
pool) read -r -d . key || zfs set tpm:jwe=$(printf "%s" "$key" | zlevis-encrypt $4) $3;;
*) zlevis-encrypt $2;;
key) zlevis-encrypt $3;;
*) exit 1;;
esac
;;
*) exit 1;;