Created
June 23, 2023 20:30
-
-
Save jwir3/b92d5f71d3ea541da8bfc81f6a492447 to your computer and use it in GitHub Desktop.
Script for checking whether a yubikey is present
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/bash | |
# | |
# A script to determine if a yubikey is present on the current host | |
# | |
RESULT=`2>&1 gpg --card-status` | |
CARD_ABSENT=`echo $RESULT | grep "OpenPGP card not available"` | |
if [ -z "${CARD_ABSENT}" ] | |
then | |
SAVEIFS=$IFS # Save current IFS (Internal Field Separator) | |
IFS=$'\n' # Change IFS to newline char | |
lines=($RESULT) | |
IFS=$SAVEIFS # Restore original IFS | |
SIGNATURE=`echo ${lines[17]} | awk -F":" '{print $2}'` | |
if [ -z "${SIGNATURE}" ] | |
then | |
echo "false" | |
else | |
echo "true" | |
fi | |
else | |
echo "false" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment