]> code.delx.au - monosys/commitdiff
Added ssh-agent script
authorJames Bunton <jamesbunton@fastmail.fm>
Fri, 21 Sep 2007 02:21:22 +0000 (12:21 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Fri, 21 Sep 2007 02:21:22 +0000 (12:21 +1000)
scripts/ssh-agent-setup [new file with mode: 0755]

diff --git a/scripts/ssh-agent-setup b/scripts/ssh-agent-setup
new file mode 100755 (executable)
index 0000000..109f270
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+source ~/.ssh_agent_env
+
+# If the agent is running then exit without doing anything
+if [ -n "${SSH_AGENT_PID}" ]; then
+       if ps -o pid= -p "${SSH_AGENT_PID}" | grep -q "${SSH_AGENT_PID}"; then
+               exit 0
+       fi
+fi
+
+echo 'Starting SSH agent...'
+ssh-agent | grep -v 'echo Agent pid' > ~/.ssh_agent_env
+source ~/.ssh_agent_env
+ssh-add
+echo 'Agent now running!'
+