#!/bin/sh
# SPDX-License-Identifier: MIT


[ "$1" = "prereqs" ] && { echo zfs; exit; }
. /usr/share/initramfs-tools/hook-functions


# Bit of a hack: replace zfs-intramfs' decrypt_fs() in /scripts/zfs with our version that understands tzpfms fzifdso datasets,
#                which should be compatible with other hooks doing the same thing
[ "${verbose:-n}" = "y" ] && echo "Patching /scripts/zfs"
sed -Ei 's/^decrypt_fs\(\)/__fzifdso__&/' "$DESTDIR/scripts/zfs"
cat /usr/share/fzifdso/initramfs-tools-zfs-patch.sh >> "$DESTDIR/scripts/zfs"


for x in zfs-tpm-list zfs-fido2-load-key; do
	xloc="$(command -v "$x")" && copy_exec "$xloc"
done


manual_add_modules hid-generic usbhid
