Last active
April 1, 2024 21:57
-
-
Save barezina/19b002f94c15674ec1c570ec0441b89e to your computer and use it in GitHub Desktop.
a script to initramfs that allows for keyfiles on USB drives to be used to unlock 22.04 disks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
file="usbtries.txt" | |
if [ -e ${file} ]; then | |
count=$(cat ${file}) | |
else | |
count=0 | |
fi | |
count=$((count+1)) | |
echo ${count} > ${file} | |
if [ "$count" -gt 3 ]; then | |
/lib/cryptsetup/askpass "USB Unlock Key Not Found, Please enter your password: " | |
exit; | |
fi | |
if [ ! -e /mnt ]; then | |
mkdir -p /mnt | |
sleep 3 | |
fi | |
if mount /dev/disk/by-label/linux-key /mnt 2>/dev/null; then | |
if [ -e /mnt/linux.key ]; then | |
cat /mnt/linux.key | |
exit | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment