summaryrefslogtreecommitdiff
path: root/pcr/mkinitcpio-openswap/openswap.hook
blob: ead4c4f869bbb60acf15571dda94e2bfc0626c10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
run_hook ()
{
    ## read openswap configurations
    source openswap.conf

    if [ -z "$keyfile_device" ] || [ -z "$keyfile_filename" ]
    then
      ## case when no keyfile provided in configurations
      cryptsetup open "$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
}