Created
January 31, 2014 11:51
-
-
Save ilovezfs/8730681 to your computer and use it in GitHub Desktop.
openLUKS from prometheanfire
This file contains 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
openLUKS() { | |
read -s -p "Password: " password | |
local RETRY_COUNT=3 | |
echo "" | |
while [ $RETRY_COUNT -ne 0 ]; do | |
RETRY_COUNT=$(( RETRY_COUNT - 1 )) | |
for disk in a b c d e f g h i j k l m n o p q r s t u v w x y z; do | |
if [ -b /dev/sd${disk}2 ]; then | |
echo -n ${password} | gpg -q -d --no-tty --passphrase-fd 0 /mnt/key/decrypt.gpg | cryptsetup -q --key-file=- luksOpen /dev/sd${disk}2 crypt${disk}2 | |
STATUS=$? | |
if [ $STATUS -ne 0 ]; then | |
echo "exit code was $STATUS" | |
echo 'bad password' | |
read -s -p "Password: " password | |
break | |
else | |
RETRY_COUNT=0 | |
fi | |
else | |
echo "no disk named /dev/sd${disk}2" | |
fi | |
done | |
done | |
unset password | |
umount /mnt/key | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment