Test if Luks is available and try to open it
This commit is contained in:
parent
5344598918
commit
2e43d4f855
|
@ -20,6 +20,28 @@ new_hostname=""
|
||||||
vgname=$(vgdisplay --short | tail -n 1 | sed 's/.*"\(.*\)" .*/\1/')
|
vgname=$(vgdisplay --short | tail -n 1 | sed 's/.*"\(.*\)" .*/\1/')
|
||||||
## If the script should create extra volume (eg. backup, virt, Proxmox,…)
|
## If the script should create extra volume (eg. backup, virt, Proxmox,…)
|
||||||
manage_extra_lv=0
|
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 {{{
|
## Is BTRFS {{{
|
||||||
root_fs_type=$(lsblk -f /dev/mapper/"${vgname}"-root | awk '/root/ { print $2 }')
|
root_fs_type=$(lsblk -f /dev/mapper/"${vgname}"-root | awk '/root/ { print $2 }')
|
||||||
if [ "${root_fs_type}" = "btrfs" ]; then
|
if [ "${root_fs_type}" = "btrfs" ]; then
|
||||||
|
|
Loading…
Reference in New Issue