Optimized root variables

This commit is contained in:
Kevin Veen-Birkenbach 2020-10-01 21:01:06 +02:00
parent 131d677bb8
commit b60b0c0d2b
2 changed files with 11 additions and 6 deletions

View File

@ -44,12 +44,17 @@ make_working_folder(){
error error
} }
set_root_variables(){
info "Setting root variables..." &&
root_partition_uuid=$(blkid "$root_partition_path" -s UUID -o value) &&
root_mapper_name="arch-root-$root_partition_uuid" &&
root_mapper_path="/dev/mapper/$root_mapper_name" || error
}
mount_partitions(){ mount_partitions(){
if [ "$(blkid "$root_partition_path" -s TYPE -o value)" == "crypto_LUKS" ] if [ "$(blkid "$root_partition_path" -s TYPE -o value)" == "crypto_LUKS" ]
then then
root_partition_uuid=$(blkid "$root_partition_path" -s UUID -o value) && set_root_variables &&
root_mapper_name="arch-root-$root_partition_uuid" &&
root_mapper_path="/dev/mapper/$root_mapper_name" &&
info "Decrypting of $root_partition_path is neccessary..." && info "Decrypting of $root_partition_path is neccessary..." &&
sudo cryptsetup -v luksOpen "$root_partition_path" "$root_mapper_name" || sudo cryptsetup -v luksOpen "$root_partition_path" "$root_mapper_name" ||
error error
@ -78,7 +83,7 @@ destructor(){
if [ "$(blkid "$root_partition_path" -s TYPE -o value)" == "crypto_LUKS" ] if [ "$(blkid "$root_partition_path" -s TYPE -o value)" == "crypto_LUKS" ]
then then
info "Trying to close decrypted $root_mapper_name..." && info "Trying to close decrypted $root_mapper_name..." &&
sudo cryptsetup -v luksClose $root_mapper_name || warning "Failed." sudo cryptsetup -v luksClose "$root_mapper_name" || warning "Failed."
fi fi
} }

View File

@ -243,8 +243,8 @@ if [ "$transfer_image" = "y" ]
if [ "$encrypt_system" == "y" ] if [ "$encrypt_system" == "y" ]
then then
info "Formating $root_partition_path with LUKS..." && info "Formating $root_partition_path with LUKS..." &&
sudo cryptsetup -v luksFormat -c aes-xts-plain64 -s 512 -h sha512 --use-random -i 1000 "$root_partition_path" || sudo cryptsetup -v luksFormat -c aes-xts-plain64 -s 512 -h sha512 --use-random -i 1000 "$root_partition_path" &&
error set_root_variables || error
fi fi
info "Format root partition..." && info "Format root partition..." &&