Skip to content

Instantly share code, notes, and snippets.

@barezina
Last active April 1, 2024 21:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save barezina/19b002f94c15674ec1c570ec0441b89e to your computer and use it in GitHub Desktop.
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
#!/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