Last active
January 25, 2016 14:28
-
-
Save zuloo/81784afe2d633fc31323 to your computer and use it in GitHub Desktop.
change the smart card reader used by gnupg2 (the dirty way)
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
#!/bin/bash | |
gpg2 --card-status > /dev/null 2>&1 | |
READERS=($(echo scd getinfo reader_list | gpg-connect-agent –decode | awk '/^D/ {print $2}' | sed 's/%0A/ /g; /^$/d')) | |
BADCHOICE=true | |
while $BADCHOICE | |
do | |
INDEX=0 | |
for READER in "${READERS[@]}" | |
do | |
INDEX=$(( INDEX + 1)) | |
echo ${INDEX}: ${READER} $(lsusb | grep -i ${READER//:X:0} | cut -d" " -f7-) | |
done | |
echo | |
echo -n "Enter your choice [1-${INDEX}]:" | |
read CHOICE | |
[ $CHOICE -le $INDEX ] && [ $CHOICE -ge 1 ] && BADCHOICE=false || echo "Error: Bad option!" | |
echo | |
done | |
CHOICE=$((CHOICE-1)) | |
echo "reader-port ${READERS[$CHOICE]}" > ~/.gnupg/scdaemon.conf | |
killall -9 scdaemon | |
sleep 2 | |
gpg2 --card-status | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment