diff --git a/debian/chroot.mount b/debian/chroot.mount index 9baa669..8a9a5f3 100755 --- a/debian/chroot.mount +++ b/debian/chroot.mount @@ -20,6 +20,28 @@ new_hostname="" vgname=$(vgdisplay --short | tail -n 1 | sed 's/.*"\(.*\)" .*/\1/') ## If the script should create extra volume (eg. backup, virt, Proxmox,…) manage_extra_lv=0 +## Is LUKS {{{ +if blkid | grep "${hdd}.*crypto_LUKS"; then + manage_luks=0 + ## You need to set a new passphrase after the installation or at least change this one + luks_passphrase="generic key" + luks_key_file="/tmp/luks.keyfile.temp" + luks_pv_name=$(basename "${hdd}"2_crypt) +else + manage_luks=1 +fi +## }}} +## Open LUKS system {{{ +if [ "${manage_luks}" -eq 0 ]; then + ### Put passphrase in a keyfile for multiple usage + rm -f -- "${luks_key_file}" && printf '%b\n' "${luks_passphrase}" > "${luks_key_file}" + ### If the volume is not already opened + if [ ! -h /dev/mapper/"${luks_pv_name}" ]; then + ### Open LUKS system + cryptsetup luksOpen "${hdd}"2 "${luks_pv_name}" --key-file "${luks_key_file}" || exit 2 + fi +fi +## }}} ## Is BTRFS {{{ root_fs_type=$(lsblk -f /dev/mapper/"${vgname}"-root | awk '/root/ { print $2 }') if [ "${root_fs_type}" = "btrfs" ]; then