summaryrefslogtreecommitdiffstats
path: root/linhes/mkinitcpio-openswap/openswap.hook
diff options
context:
space:
mode:
Diffstat (limited to 'linhes/mkinitcpio-openswap/openswap.hook')
-rw-r--r--linhes/mkinitcpio-openswap/openswap.hook9
1 files changed, 4 insertions, 5 deletions
diff --git a/linhes/mkinitcpio-openswap/openswap.hook b/linhes/mkinitcpio-openswap/openswap.hook
index 9a96ad4..3a237c0 100644
--- a/linhes/mkinitcpio-openswap/openswap.hook
+++ b/linhes/mkinitcpio-openswap/openswap.hook
@@ -11,15 +11,14 @@ run_hook ()
done
## End of optional
- if [ -z "$keyfile_device" ] || [ -z "$keyfile_filename" ]
- then
- ## case when no keyfile provided in configurations
+ if [ "$unlock_method" = "password" ]; then
cryptsetup open $cryptsetup_options "$swap_device" "$crypt_swap_name"
- else
- ## case when keyfile is provided in configurations
+ elif [ "$unlock_method" = "keyfile" ]; then
mkdir openswap_keymount
mount $keyfile_device_mount_options "$keyfile_device" openswap_keymount
cryptsetup open $cryptsetup_options --key-file "openswap_keymount/$keyfile_filename" "$swap_device" "$crypt_swap_name"
umount openswap_keymount
+ elif [ "$unlock_method" = "keyfile_raw" ]; then
+ dd "if=$keyfile_device" "bs=$keyfile_length" "skip=$keyfile_block_number" count=1 | cryptsetup open --key-file=- "$swap_device" "$crypt_swap_name"
fi
}