1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-01 23:57:05 +00:00

encryption-at-rest: Ensure required kernel modules are installed

This commit is contained in:
downtownallday 2024-09-02 16:11:13 -04:00
parent 87174e5505
commit a79a6c00eb
3 changed files with 10 additions and 0 deletions

View File

@ -44,6 +44,7 @@ if [ ! -e "$EHDD_IMG" ]; then
echo ""
echo "NOTE: You will need to reenter your drive encryption password"
fi
assert_kernel_modules
cryptsetup luksOpen $(keyfile_option) $loop $EHDD_LUKS_NAME # map device to /dev/mapper/NAME
mke2fs -j /dev/mapper/$EHDD_LUKS_NAME
# sleep a brief time to avoid "device busy"

View File

@ -17,10 +17,18 @@ if [ -z "${STORAGE_ROOT:-}" ]; then
fi
fi
EHDD_IMG="$STORAGE_ROOT.HDD"
EHDD_MOUNTPOINT="$STORAGE_ROOT"
EHDD_LUKS_NAME="c1"
assert_kernel_modules() {
local check="$(lsmod | awk '$1=="dm_crypt" {print "yes"}')"
if [ "$check" != "yes" ]; then
echo "Required kernel modules for encryption-at-rest are not loaded. Cannot continue"
exit 1
fi
}
find_unused_loop() {
losetup -f

View File

@ -21,6 +21,7 @@ if is_mounted; then
exit 0
fi
assert_kernel_modules
loop=$(find_unused_loop)
losetup $loop "$EHDD_IMG" || exit 1
# map device to /dev/mapper/NAME