Optimized logic for luks and implemented administrator setup

This commit is contained in:
2024-07-22 21:23:03 +02:00
parent 9519b314e9
commit bbb54a4237
2 changed files with 53 additions and 16 deletions

View File

@@ -33,16 +33,6 @@ create_luks_key_and_update_cryptab(){
fi
sudo dd if=/dev/urandom of="$secret_key_path" bs=512 count=8 &&
# Check if luks_memory_cost is defined and set the luksAddKey command accordingly
# @see https://chatgpt.com/share/008ea5f1-670c-467c-8320-1ca67f25ac9a
if [ -n "$luks_memory_cost" ]; then
info "Adding key with --pbkdf-memory set to $luks_memory_cost" &&
sudo cryptsetup -v luksAddKey "$2" "$secret_key_path" --pbkdf-memory "$luks_memory_cost" &&
else
info "Adding key without --pbkdf-memory parameter" &&
sudo cryptsetup -v luksAddKey "$2" "$secret_key_path" &&
fi
info "Opening and closing device to verify that everything works fine..." &&
sudo cryptsetup -v luksClose "$1" || info "No need to luksClose $1." &&
sudo cryptsetup -v luksOpen "$2" "$1" --key-file="$secret_key_path" &&