| 1 | #!/data/data/com.termux/files/usr/bin/sh |
| 2 | # source-ssh-agent: Script to source for ssh-agent to work. |
| 3 | |
| 4 | # Check if accidentaly executed instead of sourced: |
| 5 | if echo "$0" | grep -q source-ssh-agent; then |
| 6 | echo "source-ssh-agent: Do not execute directly - source me instead!" |
| 7 | exit 1 |
| 8 | fi |
| 9 | |
| 10 | export SSH_AUTH_SOCK=$PREFIX/tmp/ssh-agent |
| 11 | |
| 12 | start_agent () { |
| 13 | rm -f $SSH_AUTH_SOCK |
| 14 | ssh-agent -a $SSH_AUTH_SOCK > /dev/null |
| 15 | ssh-add |
| 16 | } |
| 17 | |
| 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 |
| 25 | fi |