-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreload_yubi.sh
More file actions
executable file
·43 lines (27 loc) · 894 Bytes
/
reload_yubi.sh
File metadata and controls
executable file
·43 lines (27 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
#
# Script to restart yubi.
#
# Sometimes the GPG agent will stop working correctly and the only
# way to get it working was to disconnect and reconnect Yubikey. This
# will do it via sw.
#
# Author: Xoores <whyxoores.cz>
. /scripts/_common.sh
YUBI_USB_PID="1050:0406"
YUBI_COUNT="$(lsusb -d "${YUBI_USB_PID}" | wc -l)"
BOOTSTRAP_ROOT
if [ "${YUBI_COUNT}" -ne 1 ]; then
LOG_ERR "Invalid YUBI_COUNT, expected 1 and got ${YUBI_COUNT}"
exit 1
fi
killall gpg-agent 2>/dev/null
while read -r USBDEV; do
USB_DEVID="$(basename "$(dirname "${USBDEV}")")"
echo "> ${USBDEV} -> ${USB_DEVID}"
LOG_DBG "Found Yubi as USB ${USB_DEVID} -> will unbind/bind"
echo "${USB_DEVID}" > /sys/bus/usb/drivers/usb/unbind
sleep .5
echo "${USB_DEVID}" > /sys/bus/usb/drivers/usb/bind
done < <(grep -li "yubikey" /sys/bus/usb/devices/*/* 2>/dev/null)
/etc/init.d/pcscd restart