mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-03 00:07:05 +00:00
encryption-at-rest: Ensure required kernel modules are installed
This commit is contained in:
parent
87174e5505
commit
a79a6c00eb
@ -44,6 +44,7 @@ if [ ! -e "$EHDD_IMG" ]; then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "NOTE: You will need to reenter your drive encryption password"
|
echo "NOTE: You will need to reenter your drive encryption password"
|
||||||
fi
|
fi
|
||||||
|
assert_kernel_modules
|
||||||
cryptsetup luksOpen $(keyfile_option) $loop $EHDD_LUKS_NAME # map device to /dev/mapper/NAME
|
cryptsetup luksOpen $(keyfile_option) $loop $EHDD_LUKS_NAME # map device to /dev/mapper/NAME
|
||||||
mke2fs -j /dev/mapper/$EHDD_LUKS_NAME
|
mke2fs -j /dev/mapper/$EHDD_LUKS_NAME
|
||||||
# sleep a brief time to avoid "device busy"
|
# sleep a brief time to avoid "device busy"
|
||||||
|
@ -17,10 +17,18 @@ if [ -z "${STORAGE_ROOT:-}" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
EHDD_IMG="$STORAGE_ROOT.HDD"
|
EHDD_IMG="$STORAGE_ROOT.HDD"
|
||||||
EHDD_MOUNTPOINT="$STORAGE_ROOT"
|
EHDD_MOUNTPOINT="$STORAGE_ROOT"
|
||||||
EHDD_LUKS_NAME="c1"
|
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() {
|
find_unused_loop() {
|
||||||
losetup -f
|
losetup -f
|
||||||
|
@ -21,6 +21,7 @@ if is_mounted; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
assert_kernel_modules
|
||||||
loop=$(find_unused_loop)
|
loop=$(find_unused_loop)
|
||||||
losetup $loop "$EHDD_IMG" || exit 1
|
losetup $loop "$EHDD_IMG" || exit 1
|
||||||
# map device to /dev/mapper/NAME
|
# map device to /dev/mapper/NAME
|
||||||
|
Loading…
Reference in New Issue
Block a user