From: Holger Levsen Date: Tue, 5 Mar 2013 14:17:45 +0000 (+0100) Subject: kill ssh-agent after using it X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=53cd240942c9301e6d0f5be495d4c3fe234c0b15;p=profitbricks%2Fjenkins-build-scripts.git kill ssh-agent after using it --- diff --git a/liveboot_gw_autotest.sh b/liveboot_gw_autotest.sh index 69eb02e..caf630c 100755 --- a/liveboot_gw_autotest.sh +++ b/liveboot_gw_autotest.sh @@ -25,6 +25,17 @@ source $TMPFILE ssh-add ~/.ssh/id_ritest rm $TMPFILE +kill_ssh_agent() { + if [ "$SSH_AGENT_PID" != "" ] ; then + kill $SSH_AGENT_PID + fi +} + +# +# trap failures +# +trap kill_ssh_agent INT TERM EXIT ERR KILL STOP ABRT + # # temp. until fabian has fixed liveboot # @@ -55,4 +66,8 @@ ssh -t $CORE_ROUTER "cd /opt/autotest ; git checkout develop" #ssh -t -A $CORE_ROUTER "cd /opt/autotest ; ./run-compile.sh --config config-jenkins.xml" ssh -t -A $CORE_ROUTER "cd /opt/autotest ; ./run-compile.sh" - +# +# remove trap +# +trap - INT TERM EXIT ERR KILL STOP ABRT +kill_ssh_agent diff --git a/pxe_install.sh b/pxe_install.sh index b4e67d3..b7cf0f1 100755 --- a/pxe_install.sh +++ b/pxe_install.sh @@ -55,6 +55,7 @@ echo figlet $TARGET_HOST echo "successfully installed" + # # prepare ssh # @@ -64,6 +65,20 @@ source $TMPFILE ssh-add ~/.ssh/id_ritest rm $TMPFILE +kill_ssh_agent() { + if [ "$SSH_AGENT_PID" != "" ] ; then + kill $SSH_AGENT_PID + fi +} + +# +# trap failures +# +trap kill_ssh_agent INT TERM EXIT ERR KILL STOP ABRT + +# +# check system +# ssh -t $TARGET_HOST uname -a echo ssh -t $TARGET_HOST "dpkg -l | egrep '(profit|bird|vcb|ofed|qemu|kvm)' | sort -k 50" @@ -72,3 +87,9 @@ ssh -t $TARGET_HOST dpkg -l | grep develop || true echo ssh -t $TARGET_HOST "cat /etc/apt/sources.list.d/* /etc/apt/sources.list|grep -v ^#|sort -u" +# +# remove trap +# +trap - INT TERM EXIT ERR KILL STOP ABRT +kill_ssh_agent +