2020-07-06 11:40:19 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
set -x
|
2021-07-07 16:26:58 +02:00
|
|
|
which dnf >/dev/null 2>&1 [ -z "${P11M+x}" ] && P11M="$(dnf repoquery --installed -l p11-kit | grep \/p11-kit-proxy.so\$ | head -1)"
|
|
|
|
which dpkg >/dev/null 2>&1 && [ -z "${P11M+x}" ] && P11M="$(dpkg -L p11-kit-modules|grep \/p11-kit-proxy.so\$ | head -1)"
|
|
|
|
|
2020-07-06 11:40:19 +02:00
|
|
|
|
|
|
|
echo SSH_AGENT_PID before: $SSH_AGENT_PID
|
|
|
|
|
|
|
|
[ -z "$(pidof ssh-agent)" -o "${SSH_AGENT_PID}" != "$(pidof ssh-agent)" ] && eval "$(ssh-agent -s)"
|
|
|
|
|
|
|
|
|
|
|
|
echo SSH_AGENT_PID after: $SSH_AGENT_PID
|
|
|
|
|
2021-05-06 00:56:01 +02:00
|
|
|
#if ssh-add -l | grep -q "${P11M}"; then
|
2020-07-06 11:40:19 +02:00
|
|
|
# # Remove any stale loaded keys from token, ssh-agent does not automatically
|
|
|
|
# # reconnect with the token when you reinsert it.
|
2021-05-06 00:56:01 +02:00
|
|
|
# ssh-add -e "${P11M}"
|
2020-07-06 11:40:19 +02:00
|
|
|
#fi
|
|
|
|
|
2021-05-06 00:56:01 +02:00
|
|
|
ssh-add -e "${P11M}" 2>/dev/null
|
2020-07-06 11:40:19 +02:00
|
|
|
echo $?
|
|
|
|
# Tell ssh-agent to use the keys on the token
|
2021-05-06 00:56:01 +02:00
|
|
|
ssh-add -s "${P11M}"
|