added packages

This commit is contained in:
2023-04-29 00:31:15 +05:30
parent 6c0edc5379
commit cb7808a9bd
78 changed files with 5393 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# Maintainer: Jenya Sovetkin <e.sovetkin@gmail.com>
# Contributors: https://aur.archlinux.org/account/f4bio
pkgname=mkinitcpio-openswap
pkgver=0.1.0
pkgrel=3
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')
sha256sums=('84ef428386b7f4353af036ccfbd4c60901a76e2d0c7a38dd3be2000219ea9d23'
'94dd98a953bab2244215a2b20767cdc9500fc438bed9ec27cae72a73766c6b86'
'3308f2679bb7c962d98adf2684d25390025d025e3d30bc1e773e3522311ad325')
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"
}

View File

@ -0,0 +1,17 @@
## cryptsetup open $swap_device $crypt_swap_name
## get uuid using e.g. lsblk -f
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 mount for keyfile_device
## has to start with --options (if so desired)
#keyfile_device_mount_options="--options=subvol=__active/__"
## additional arguments are given to cryptsetup
## --allow-discards options is desired in case swap is on SSD partition
cryptsetup_options="--type luks"

View File

@ -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
}

View File

@ -0,0 +1,27 @@
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 "keyfile_device_mount_options=" /etc/openswap.conf >> "$BUILDROOT/openswap.conf"
grep "cryptsetup_options=" /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
}

View File

@ -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 ""
}