*: refactor

Documentation will be rewritten and added later.
This commit is contained in:
illiliti
2021-07-31 20:20:16 +03:00
parent 7bfc7fe315
commit a468c11a30
45 changed files with 618 additions and 2161 deletions

36
hook/luks/luks Normal file
View File

@@ -0,0 +1,36 @@
# vim: set ft=sh:
# shellcheck shell=sh
#
# https://shellcheck.net/wiki/SC2154
# shellcheck disable=2154
[ "$luks_key" ] && {
copy_file "${luks_key#*=}" /root/luks_key 0400
sed "s|${luks_key#*=}|/root/luks_key|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"
mv "${tmpdir}/_" "${tmpdir}/etc/tinyramfs/config"
}
[ "$luks_header" ] && {
copy_file "${luks_header#*=}" /root/luks_header 0400
sed "s|${luks_header#*=}|/root/luks_header|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"
mv "${tmpdir}/_" "${tmpdir}/etc/tinyramfs/config"
}
[ "$hostonly" ] &&
for _mod in \
aes ecb xts lrw wp512 sha256 \
sha512 twofish serpent dm-crypt
do
copy_kmod "$_mod"
done
# https://bugs.archlinux.org/task/56771
[ -e /lib/libgcc_s.so.1 ] && copy_file /lib/libgcc_s.so.1 /lib/libgcc_s.so.1 0755 1
copy_exec cryptsetup

15
hook/luks/luks.init Normal file
View File

@@ -0,0 +1,15 @@
# vim: set ft=sh:
# shellcheck shell=sh
#
# https://shellcheck.net/wiki/SC2154
# shellcheck disable=2154
mkdir -p /run/cryptsetup
resolve_device "$luks_root"
DM_DISABLE_UDEV=1 cryptsetup open \
${luks_discard:+--allow-discards} \
${luks_header:+--header="$luks_header"} \
${luks_key:+--key-file="$luks_key"} -- "$device" \
"${luks_name:-crypt-${device##*/}}" || panic "failed to unlock LUKS"