Commit | Line | Data |
---|---|---|
2f5fc713 FF |
1 | #!/data/data/com.termux/files/usr/bin/sh |
2 | # source-ssh-agent: Script to source for ssh-agent to work. | |
59f0d218 FF |
3 | |
4 | # Check if accidentaly executed instead of sourced: | |
5 | if echo "$0" | grep -q source-ssh-agent; then | |
2f5fc713 FF |
6 | echo "source-ssh-agent: Do not execute directly - source me instead!" |
7 | exit 1 | |
59f0d218 FF |
8 | fi |
9 | ||
2f5fc713 | 10 | export SSH_AUTH_SOCK=$PREFIX/tmp/ssh-agent |
59f0d218 FF |
11 | |
12 | start_agent () { | |
2f5fc713 FF |
13 | rm -f $SSH_AUTH_SOCK |
14 | ssh-agent -a $SSH_AUTH_SOCK > /dev/null | |
15 | ssh-add | |
59f0d218 FF |
16 | } |
17 | ||
2f5fc713 FF |
18 | MESSAGE=`ssh-add -L 2>&1` |
19 | if [ "$MESSAGE" = 'Could not open a connection to your authentication agent.' -o \ | |
20 | "$MESSAGE" = 'Error connecting to agent: Connection refused' -o \ | |
21 | "$MESSAGE" = 'Error connecting to agent: No such file or directory' ]; then | |
22 | start_agent | |
23 | elif [ "$MESSAGE" = "The agent has no identities." ]; then | |
24 | ssh-add | |
59f0d218 | 25 | fi |