diff options
author | Britney Fransen <brfransen@gmail.com> | 2022-11-11 03:23:55 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2022-11-11 03:23:55 (GMT) |
commit | 98920007f3377fc8adcf40791b97dff55a7af0d9 (patch) | |
tree | 4857e7d97a0b0ac4d666936f77675361319ffda8 /linhes/mkinitcpio-openswap/openswap.hook | |
parent | 8896dbb865bfecfd6dd9277d07db8f1453c607a5 (diff) | |
download | linhes_pkgbuild-98920007f3377fc8adcf40791b97dff55a7af0d9.zip linhes_pkgbuild-98920007f3377fc8adcf40791b97dff55a7af0d9.tar.gz linhes_pkgbuild-98920007f3377fc8adcf40791b97dff55a7af0d9.tar.bz2 |
mkinitcpio-openswap: initial inclusion
Diffstat (limited to 'linhes/mkinitcpio-openswap/openswap.hook')
-rw-r--r-- | linhes/mkinitcpio-openswap/openswap.hook | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/linhes/mkinitcpio-openswap/openswap.hook b/linhes/mkinitcpio-openswap/openswap.hook new file mode 100644 index 0000000..9a96ad4 --- /dev/null +++ b/linhes/mkinitcpio-openswap/openswap.hook @@ -0,0 +1,25 @@ +run_hook () +{ + ## read openswap configurations + source /openswap.conf + + ## Optional: To avoid race conditions + x=0; + while [ ! -b "$keyfile_device" ] && [ $x -le 10 ]; do + x=$((x+1)) + sleep .2 + done + ## End of optional + + if [ -z "$keyfile_device" ] || [ -z "$keyfile_filename" ] + then + ## case when no keyfile provided in configurations + cryptsetup open $cryptsetup_options "$swap_device" "$crypt_swap_name" + else + ## case when keyfile is provided in configurations + 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 + fi +} |