diff options
author | Eugene Sovetkin | 2015-06-08 11:06:08 +0200 |
---|---|---|
committer | Eugene Sovetkin | 2015-06-08 11:06:08 +0200 |
commit | 05c09af0c87fbcee537ba5c4400acedadf3171d7 (patch) | |
tree | 8af917aeb1e568d0e58d2df2017d83368ac2d0e1 | |
download | aur-05c09af0c87fbcee537ba5c4400acedadf3171d7.tar.gz |
Initial import
-rw-r--r-- | .SRCINFO | 19 | ||||
-rw-r--r-- | PKGBUILD | 27 | ||||
-rw-r--r-- | openswap.conf | 11 | ||||
-rw-r--r-- | openswap.hook | 17 | ||||
-rw-r--r-- | openswap.install | 26 | ||||
-rw-r--r-- | usage.install | 9 |
6 files changed, 109 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..e4a851664ecc --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,19 @@ +pkgbase = mkinitcpio-openswap + pkgdesc = mkinitcpio hook to open swap at boot time + pkgver = 0.0.0 + pkgrel = 2 + url = https://aur.archlinux.org/packages/mkinitcpio-openswap/ + install = usage.install + arch = any + license = unknown + depends = mkinitcpio + backup = etc/openswap.conf + source = openswap.hook + source = openswap.install + source = openswap.conf + md5sums = a5b52e3c3b5dc592f41567b21ec2e9cf + md5sums = ae743e0fd95cc1c07705cf7c472416b1 + md5sums = 8a72bf00f155512490884eb4911cc4f4 + +pkgname = mkinitcpio-openswap + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..0c6a0f1cfe91 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,27 @@ +# Maintainer: Jenya Sovetkin <e.sovetkin@gmail.com> +pkgname=mkinitcpio-openswap +pkgver=0.0.0 +pkgrel=2 +pkgdesc="mkinitcpio hook to open swap at boot time" +arch=(any) +license=('unknown') +url="https://aur.archlinux.org/packages/mkinitcpio-openswap/" +depends=(mkinitcpio) +backup=('etc/openswap.conf') +install="usage.install" +source=('openswap.hook' + 'openswap.install' + 'openswap.conf') +md5sums=('a5b52e3c3b5dc592f41567b21ec2e9cf' + 'ae743e0fd95cc1c07705cf7c472416b1' + '8a72bf00f155512490884eb4911cc4f4') + + +package() { + install -Dm 644 openswap.hook \ + "${pkgdir}/usr/lib/initcpio/hooks/openswap" + install -Dm 644 openswap.install \ + "${pkgdir}/usr/lib/initcpio/install/openswap" + install -Dm 644 openswap.conf \ + "${pkgdir}/etc/openswap.conf" +} diff --git a/openswap.conf b/openswap.conf new file mode 100644 index 000000000000..75382fc9f161 --- /dev/null +++ b/openswap.conf @@ -0,0 +1,11 @@ +## cryptsetup open $swap_device $crypt_swap_name +swap_device=/dev/disk/by-uuid/2788eb78-074d-4424-9f1d-ebffc9c37262 +crypt_swap_name=cryptswap + +## one can optionally provide a keyfile device and path on this device +## to the keyfile +keyfile_device=/dev/mapper/cryptroot +keyfile_filename=etc/keyfile-cryptswap + +## additional arguments are given to cryptsetup +miscellaneous="--type luks"
\ No newline at end of file diff --git a/openswap.hook b/openswap.hook new file mode 100644 index 000000000000..24331482913f --- /dev/null +++ b/openswap.hook @@ -0,0 +1,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" openswap_keymount + cryptsetup open $miscellaneous --key-file "openswap_keymount/$keyfile_filename" "$swap_device" "$crypt_swap_name" + umount openswap_keymount + fi +}
\ No newline at end of file diff --git a/openswap.install b/openswap.install new file mode 100644 index 000000000000..db04155fe4cc --- /dev/null +++ b/openswap.install @@ -0,0 +1,26 @@ +build () +{ + grep "swap_device=" /etc/openswap.conf > "$BUILDROOT/openswap.conf" + grep "crypt_swap_name=" /etc/openswap.conf >> "$BUILDROOT/openswap.conf" + grep "keyfile_device=" /etc/openswap.conf >> "$BUILDROOT/openswap.conf" + grep "keyfile_filename=" /etc/openswap.conf >> "$BUILDROOT/openswap.conf" + grep "miscellaneous=" /etc/openswap.conf >> "$BUILDROOT/openswap.conf" + + source "$BUILDROOT/openswap.conf" + + if [ -z "$swap_device" ]; then + warning "swap_device variable is not set" + fi + + if [ -z "$crypt_swap_name" ]; then + warning "crypt_swap_name variable is not set" + fi + + add_runscript +} +help () +{ +cat<<HELPEOF + This hook opens a swap at boot time +HELPEOF +}
\ No newline at end of file diff --git a/usage.install b/usage.install new file mode 100644 index 000000000000..3610e9d28b43 --- /dev/null +++ b/usage.install @@ -0,0 +1,9 @@ +post_install() { + echo "" + echo "Alter /etc/openswap.conf file for your swap device name, keyfiles, etc..." + echo "" + echo "For more information see: https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryption#mkinitcpio_hook" + echo "" + echo "Don't forget to add the openswap hook after encrypt and before resume in your /etc/mkinitcpio.conf and run mkinitcpio -p linux..." + echo "" +} |